Inmathematics, acombination is a selection of items from aset that has distinct members, such that the order of selection does not matter (unlikepermutations). For example, given three fruits, say an apple, an orange and a pear, there are three combinations of two that can be drawn from this set: an apple and a pear; an apple and an orange; or a pear and an orange. More formally, ak-combination of a setS is a subset ofk distinct elements ofS. So, two combinations are identicalif and only if each combination has the same members. (The arrangement of the members in each set does not matter.) If the set hasn elements, the number ofk-combinations, denoted by or, is equal to thebinomial coefficient
which can be written usingfactorials as whenever, and which is zero when. This formula can be derived from the fact that eachk-combination of a setS ofn members has permutations so or.[1] The set of allk-combinations of a setS is often denoted by.
A combination is a selection ofn things takenk at a timewithout repetition. To refer to combinations in which repetition is allowed, the termsk-combination with repetition,k-multiset,[2] ork-selection,[3] are often used.[4] If, in the above example, it were possible to have two of any one kind of fruit there would be 3 more 2-selections: one with two apples, one with two oranges, and one with two pears.
Although the set of three fruits was small enough to write a complete list of combinations, this becomes impractical as the size of the set increases. For example, apoker hand can be described as a 5-combination (k = 5) of cards from a 52 card deck (n = 52). The 5 cards of the hand are all distinct, and the order of cards in the hand does not matter. There are 2,598,960 such combinations, and the chance of drawing any one hand at random is 1 / 2,598,960.
The number ofk-combinations from a given setS ofn elements is often denoted in elementary combinatorics texts by, or by a variation such as,,, or even[5] (the last form is standard in French, Romanian, Russian, and Chinese texts).[6][7] The same number however occurs in many other mathematical contexts, where it is denoted by (often read as "n choosek"); notably it occurs as a coefficient in thebinomial formula, hence its name binomial coefficient. One can define for all natural numbersk at once by the relation
from which it is clear that
and further
for.
To see that these coefficients countk-combinations fromS, one can first consider a collection ofn distinct variablesXs labeled by the elementss ofS, and expand theproduct over all elements of S:
it has 2n distinct terms corresponding to all the subsets ofS, each subset giving the product of the corresponding variablesXs. Now setting all of theXs equal to the unlabeled variableX, so that the product becomes(1 +X)n, the term for eachk-combination fromS becomesXk, so that the coefficient of that power in the result equals the number of suchk-combinations.
Binomial coefficients can be computed explicitly in various ways. To get all of them for the expansions up to(1 +X)n, one can use (in addition to the basic cases already given) the recursion relation
for 0 <k <n, which follows from(1 +X)n= (1 +X)n − 1(1 +X); this leads to the construction ofPascal's triangle.
For determining an individual binomial coefficient, it is more practical to use the formula
Thenumerator gives the number ofk-permutations ofn, i.e., of sequences ofk distinct elements ofS, while thedenominator gives the number of suchk-permutations that give the samek-combination when the order is ignored.
Whenk exceedsn/2, the above formula contains factors common to the numerator and the denominator, and canceling them out gives the relation
for 0 ≤k ≤n. This expresses a symmetry that is evident from the binomial formula, and can also be understood in terms ofk-combinations by taking thecomplement of such a combination, which is an(n −k)-combination.
Finally there is a formula which exhibits this symmetry directly, and has the merit of being easy to remember:
wheren! denotes thefactorial ofn. It is obtained from the previous formula by multiplying denominator and numerator by(n −k)!, so it is certainly computationally less efficient than that formula.
The last formula can be understood directly, by considering then! permutations of all the elements ofS. Each such permutation gives ak-combination by selecting its firstk elements. There are many duplicate selections: any combined permutation of the firstk elements among each other, and of the final (n − k) elements among each other produces the same combination; this explains the division in the formula.
From the above formulas follow relations between adjacent numbers in Pascal's triangle in all three directions:
Together with the basic cases, these allow successive computation of respectively all numbers of combinations from the same set (a row in Pascal's triangle), ofk-combinations of sets of growing sizes, and of combinations with a complement of fixed sizen −k.
As a specific example, one can compute the number of five-card hands possible from a standard fifty-two card deck as:[8]
Alternatively one may use the formula in terms of factorials and cancel the factors in the numerator against parts of the factors in the denominator, after which only multiplication of the remaining factors is required:
Another alternative computation, equivalent to the first, is based on writing
which gives
When evaluated in the following order,52 ÷ 1 × 51 ÷ 2 × 50 ÷ 3 × 49 ÷ 4 × 48 ÷ 5, this can be computed using only integer arithmetic. The reason is that when each division occurs, the intermediate result that is produced is itself a binomial coefficient, so no remainders ever occur.
Using the symmetric formula in terms of factorials without performing simplifications gives a rather extensive calculation:
One canenumerate allk-combinations of a given setS ofn elements in some fixed order, which establishes abijection from an interval of integers with the set of thosek-combinations. AssumingS is itself ordered, for instanceS = { 1, 2, ...,n }, there are two natural possibilities for ordering itsk-combinations: by comparing their smallest elements first (as in the illustrations above) or by comparing their largest elements first. The latter option has the advantage that adding a new largest element toS will not change the initial part of the enumeration, but just add the newk-combinations of the larger set after the previous ones. Repeating this process, the enumeration can be extended indefinitely withk-combinations of ever larger sets. If moreover the intervals of the integers are taken to start at 0, then thek-combination at a given placei in the enumeration can be computed easily fromi, and the bijection so obtained is known as thecombinatorial number system. It is also known as "rank"/"ranking" and "unranking" in computational mathematics.[9][10]
There are many ways to enumeratek combinations. One way is to trackk index numbers of the elements selected, starting with {0 ..k−1} (zero-based) or {1 ..k} (one-based) as the first allowedk-combination. Then, repeatedly move to the next allowedk-combination by incrementing the smallest index number for which this would not create two equal index numbers, at the same time resetting all smaller index numbers to their initial values.
Ak-combination with repetitions, ork-multicombination, ormultisubset of sizek from a setS of sizen is given by a set ofk not necessarily distinct elements ofS, where order is not taken into account: two sequences define the same multiset if one can be obtained from the other by permuting the terms. In other words, it is a sample ofk elements from a set ofn elements allowing for duplicates (i.e., with replacement) but disregarding different orderings (e.g. {2,1,2} = {1,2,2}). Associate an index to each element ofS and think of the elements ofS astypes of objects, then we can let denote the number of elements of typei in a multisubset. The number of multisubsets of sizek is then the number of nonnegative integer (so allowing zero) solutions of theDiophantine equation:[11]
IfS hasn elements, the number of suchk-multisubsets is denoted by
a notation that is analogous to thebinomial coefficient which countsk-subsets. This expression,n multichoosek,[12] can also be given in terms of binomial coefficients:
This relationship can be easily proved using a representation known asstars and bars.[13]
Proof
A solution of the above Diophantine equation can be represented bystars, a separator (abar), then more stars, another separator, and so on. The total number of stars in this representation isk and the number of bars isn - 1 (since a separation into n parts needs n-1 separators). Thus, a string ofk +n - 1 (orn +k - 1) symbols (stars and bars) corresponds to a solution if there arek stars in the string. Any solution can be represented by choosingk out ofk +n − 1 positions to place stars and filling the remaining positions with bars. For example, the solution of the equation (n = 4 andk = 10) can be represented by[14]
The number of such strings is the number of ways to place 10 stars in 13 positions, which is the number of 10-multisubsets of a set with 4 elements.
Bijection between 3-subsets of a 7-set (left) and 3-multisets with elements from a 5-set (right). This illustrates that.
As with binomial coefficients, there are several relationships between these multichoose expressions. For example, for,
This identity follows from interchanging the stars and bars in the above representation.[15]
For example, if you have four types of donuts (n = 4) on a menu to choose from and you want three donuts (k = 3), the number of ways to choose the donuts with repetition can be calculated as
This result can be verified by listing all the 3-multisubsets of the setS = {1,2,3,4}. This is displayed in the following table.[16] The second column lists the donuts you actually chose, the third column shows the nonnegative integer solutions of the equation and the last column gives the stars and bars representation of the solutions.[17]
The number ofk-combinations for allk is the number of subsets of a set ofn elements. There are several ways to see that this number is 2n. In terms of combinations,, which is the sum of thenth row (counting from 0) of thebinomial coefficients inPascal's triangle. These combinations (subsets) are enumerated by the 1 digits of the set ofbase 2 numbers counting from 0 to 2n − 1, where each digit position is an item from the set ofn.
Given 3 cards numbered 1 to 3, there are 8 distinct combinations (subsets), including theempty set:
Representing these subsets (in the same order) as base 2 numerals:
There are variousalgorithms to pick out a random combination from a given set or list.Rejection sampling is extremely slow for large sample sizes. One way to select ak-combination efficiently from a population of sizen is to iterate across each element of the population, and at each step pick that element with a dynamically changing probability of (seeReservoir sampling). Another is to pick a random non-negative integer less than and convert it into a combination using thecombinatorial number system.
A combination can also be thought of as a selection oftwo sets of items: those that go into the chosen bin and those that go into the unchosen bin. This can be generalized to any number of bins with the constraint that every item must go to exactly one bin. The number of ways to put objects into bins is given by themultinomial coefficient
wheren is the number of items,m is the number of bins, and is the number of items that go into bini.
One way to see why this equation holds is to first number the objects arbitrarily from1 ton and put the objects with numbers into the first bin in order, the objects with numbers into the second bin in order, and so on. There are distinct numberings, but many of them are equivalent, because only the set of items in a bin matters, not their order in it. Every combined permutation of each bins' contents produces an equivalent way of putting items into bins. As a result, every equivalence class consists of distinct numberings, and the number of equivalence classes is.
The binomial coefficient is the special case wherek items go into the chosen bin and the remaining items go into the unchosen bin:
^Ryser 1963, p. 7 also referred to as anunordered selection.
^When the termcombination is used to refer to either situation (as in (Brualdi 2010)) care must be taken to clarify whether sets or multisets are being discussed.
^High School Textbook for full-time student (Required) Mathematics Book II B (in Chinese) (2nd ed.). China: People's Education Press. June 2006. pp. 107–116.ISBN978-7-107-19616-4.
^人教版高中数学选修2-3 [Mathematics textbook, volume 2-3, for senior high school, People's Education Press]. People's Education Press. p. 21.Archived from the original on 7 April 2023.