Very often I need to deal with combinations and permutations. This is just a recap on high school math which I tend to lose touch on.
A combination doesn't care about the order, e.g. 123 is the same as 312
A permutation does
Imagine there are 5 numbers 1,2,3,4,5. We need to choose 3, n=5, r=3. How many combinations? How many permutations?
Permutation with repetition n^r
Imagine there are 3 slots for the 3 numbers. There's 5 number we can fill the first slot. 5 numbers we can fill the second and 5 number we can fill the third. 5*5*5 permutations.
Permutation without repetition n!/(n-r)!
There's 5 number we can fill the first slot. 4 numbers we can fill the second and 3 number we can fill the third. 5*4*3 permutations.
Combinations without repetition n!/((n-r)!r!)
Imagine permutations without repetition. Now remove the sens of permutations Hence an additional r! in the denominator.
Combinations with repetition (n+r-1)!/r!(n-1)!
This needs an unusual approach to understand, at least for me this worked out as in http://www.statlect.com/subon2/comcom1.htm
We need to order two scoops of ice cream, choosing among four flavours: chocolate, pistachio, strawberry and vanilla. It is possible to order two scoops of the same flavour. How many different combinations can we order? The number of different combinations we can order is equal to the number of possible combinations with repetition of 2 objects from 4. Let us represent an order as a string of crosses (x) and vertical bars (|), where a vertical bar delimits two adjacent flavours and a cross denotes a scoop of a given flavour. For example,
x | | | x 1 chocolate, 1 vanilla
| | x x | 2 strawberry
where the first vertical bar (the leftmost one) delimits chocolate and pistachio, the second one delimits pistachio and strawberry and the third one delimits strawberry and vanilla. Each string contains three vertical bars, one less than the number of flavours, and two crosses, one for each scoop. Therefore, each string contains a total of five symbols. Making an order is equivalent to choosing which two of the five symbols will be a cross (the remaining will be vertical bars). So, to make an order, we need to choose 2 objects from 5. The number of possible ways to choose 2 objects from 5 is equal to the number of possible combinations without repetition of 2 objects from 5, i.e 5! /(5-2)!2!
A combination doesn't care about the order, e.g. 123 is the same as 312
A permutation does
Imagine there are 5 numbers 1,2,3,4,5. We need to choose 3, n=5, r=3. How many combinations? How many permutations?
Permutation with repetition n^r
Imagine there are 3 slots for the 3 numbers. There's 5 number we can fill the first slot. 5 numbers we can fill the second and 5 number we can fill the third. 5*5*5 permutations.
Permutation without repetition n!/(n-r)!
There's 5 number we can fill the first slot. 4 numbers we can fill the second and 3 number we can fill the third. 5*4*3 permutations.
Combinations without repetition n!/((n-r)!r!)
Imagine permutations without repetition. Now remove the sens of permutations Hence an additional r! in the denominator.
Combinations with repetition (n+r-1)!/r!(n-1)!
This needs an unusual approach to understand, at least for me this worked out as in http://www.statlect.com/subon2/comcom1.htm
We need to order two scoops of ice cream, choosing among four flavours: chocolate, pistachio, strawberry and vanilla. It is possible to order two scoops of the same flavour. How many different combinations can we order? The number of different combinations we can order is equal to the number of possible combinations with repetition of 2 objects from 4. Let us represent an order as a string of crosses (x) and vertical bars (|), where a vertical bar delimits two adjacent flavours and a cross denotes a scoop of a given flavour. For example,
x | | | x 1 chocolate, 1 vanilla
| | x x | 2 strawberry
where the first vertical bar (the leftmost one) delimits chocolate and pistachio, the second one delimits pistachio and strawberry and the third one delimits strawberry and vanilla. Each string contains three vertical bars, one less than the number of flavours, and two crosses, one for each scoop. Therefore, each string contains a total of five symbols. Making an order is equivalent to choosing which two of the five symbols will be a cross (the remaining will be vertical bars). So, to make an order, we need to choose 2 objects from 5. The number of possible ways to choose 2 objects from 5 is equal to the number of possible combinations without repetition of 2 objects from 5, i.e 5! /(5-2)!2!
Comments
Post a Comment