Definitions

# combination

[kom-buh-ney-shuhn]
In combinatorial mathematics, a combination is an un-ordered collection of distinct elements, usually of a prescribed size and taken from a given set. (An ordered collection of distinct elements would sometimes be called a permutation, but that term is ambiguous.) Given such a set S, a combination of elements of S is just a subset of S, where as always for (sub)sets the order of the elements is not taken into account (two lists with the same elements in different orders are considered to be the same combination). Also, as always for (sub)sets, no elements can be repeated more than once in a combination; this is often referred to as a "collection without repetition". For instance, {1,1,2} is not a combination of three digits; as a set this is the same as {1,2,1} or as {2,1,1}. On the contrary, a poker hand can be described as a combination of 5 cards from a 52-card deck: the order of the cards doesn't matter, and there can be no identical cards among the 5.

A k-combination (or k-subset) is a subset with k elements.

## Number of k-combinations from a set

The number of k-combinations (each of size k) from a set S with n elements (size n) is the binomial coefficient (also known as the "choose function"):

$^nC_k = \left\{n choose k\right\} = frac\left\{n!\right\}\left\{k!\left(n-k\right)!\right\}.$

where n is the number of objects from which you can choose and k is the number to be chosen, and n! denotes the factorial.

The definition can be understood by considering a list of $n$ elements; the list can be ordered $n!$ ways, and for each possible ordering can be partitioned into the first $k$ elements followed by the remaining $n-k$ elements. The first partition is then a selection of $k$ elements from the original list and all those partitions from every ordering cover all such selections. The complete permutation of the original list produces duplicate selections, however; some permutations result in a permuted but identical set for the first partition, and so we divide by $k!$ to remove these, and other permutations result in permuted second partitions, and so we divide by $\left(n-k\right)!$ to remove these.

The use of the definition in calculation is not always straightforward. For example, the number of five-card hands possible from a standard fifty-two card deck is:

$\left\{52 choose 5\right\} = frac\left\{n!\right\}\left\{k!\left(n-k\right)!\right\} = frac\left\{52!\right\}\left\{5!\left(52-5\right)!\right\} = frac\left\{52!\right\}\left\{5!47!\right\} = 2598960.$

Since it is impractical to calculate n! if the value of n is very large, a more efficient algorithm is

$\left\{n choose k\right\} = frac \left\{ \left(n - 0 \right) \right\}\left\{ \left(k - 0\right) \right\} times frac \left\{ \left(n - 1 \right) \right\}\left\{ \left(k - 1\right) \right\} times frac \left\{ \left(n - 2 \right) \right\}\left\{ \left(k - 2\right) \right\} times frac \left\{ \left(n - 3 \right) \right\}\left\{ \left(k - 3\right) \right\} times cdots times frac \left\{ \left(n - \left(k - 1\right) \right) \right\}\left\{ \left(k - \left(k - 1\right)\right) \right\}.$

which gives

$\left\{52 choose 5\right\} = frac \left\{ 52 \right\}\left\{ 5 \right\} times frac \left\{ 51 \right\}\left\{ 4 \right\} times frac \left\{ 50 \right\}\left\{ 3 \right\} times frac \left\{ 49 \right\}\left\{ 2 \right\} times frac \left\{ 48 \right\}\left\{ 1 \right\} = 2598960.$

This method of calculation can be seen immediately from the recursive definition of the choose function:

$\left\{n choose k+1\right\} = \left\{n choose k\right\}frac\left\{n-k\right\}\left\{k+1\right\}$

with a base case of $\left\{nchoose 0\right\}=1$. It can be argued that $\left\{nchoose 1\right\}=n$ is a more natural base case but the former follows easily from the latter anyway.

This second definition can be understood as stating that when adding an element to the selection, there are $n-k$ elements to choose from, and so this increases the number of possible selections by that much, but doing this to all selections produces duplicates (e.g. $\left\{a,b\right\}cup\left\{c\right\}=\left\{a,c\right\}cup\left\{b\right\}$) and so we divide by the size of the selection since that is the number of possibilities for the last element added.

Since as explained above a combination is a special case of a partition of a set; specifically, a partition into two sets of size k and n − k, you get the same number of combinations if you substitute k with n − k. Therefore, when k is more than half of n, it may be easier to compute the binomial coefficient using n − k in place of k.

## Number of combinations with repetition

The number of combinations with repetition can be calculated as:

$\left\{\left\{\left(n + k - 1\right)!\right\} over \left\{k!\left(n - 1\right)!\right\}\right\} = \left\{\left\{n + k - 1\right\} choose \left\{k\right\}\right\} = \left\{\left\{n + k - 1\right\} choose \left\{n - 1\right\}\right\}$

For example, if you have ten types of donuts (n) on a menu to choose from and you want three donuts (k) there are (10 + 3 − 1)! / 3!(10 − 1)! = 220 ways to choose (see also multiset).