Awesome
Learning combinations vs permutations
Just one of the things I'm learning. https://github.com/hchiam/learning
A reference: https://www.mathsisfun.com/combinatorics/combinations-permutations.html
Combinations are different from permutations. But did you know that there are actually different kinds of combinations and different kinds of permutations?
Number of: (n
= options, r
= choose)
- permutations with repeats allowed:
n^r
- permutations without repeats (if
r == n
):n!
- permutations without repeats (if
r != n
):n! / (n-r)!
- intuition: example:
5 pick 2
=5*4
, not5*4*3*2*1
- intuition: you're picking the first 2, hence
5*4
- intuition:
n! / (n-r)!
is just a fancy math way of getting that5*4
- intuition: divide by
(unwanteds)
=(n-r)!
=3*2*1
in the example
- intuition: example:
- (combinations = permutations but order doesn't matter)
- combinations without repeats:
n! / (n-r)! / r!
- intuition:
(permutations) / (ways to order r)
- intuition:
(permutations)
=n! / (n-r)!
- intuition:
(ways to order r)
=r!
- intuition:
- combinations with repeats allowed:
(n-1 + r)! / (n-1)! / r!
To-do:
Understand why there's -1
s in the equation for combinations with repeats allowed.
The rest of that last equation makes sense:
n
to be combined +r
repeats allowed =(n + r)!
permutations/n!r!
to remove the ways to ordern
items andr
items- both of the above give you
(n+r)! / n!r!
"combinations"
So why the -1
on the top and bottom?