


Inmathematics, and in particular incombinatorics, thecombinatorial number system of degreek (for some positiveintegerk), also referred to ascombinadics, or theMacaulay representation of an integer, is a correspondence betweennatural numbers (taken to include 0)N andk-combinations. The combinations are represented asstrictly decreasingsequencesck > ... > c2 > c1 ≥ 0 where eachci corresponds to the index of a chosen element in a givenk-combination. Distinct numbers correspond to distinctk-combinations, and produce them inlexicographic order. The numbers less than correspond to allk-combinations of{0, 1, ...,n − 1}. The correspondence does not depend on the size n of the set that thek-combinations are taken from, so it can be interpreted as a map fromN to thek-combinations taken fromN; in this view the correspondence is abijection.
The numberN corresponding to (ck, ...,c2,c1) is given by
The fact that a combination corresponds to a non-negative integer was observed byLehmer (1964).[1] Indeed, agreedy algorithm finds thek-combination corresponding toN: takeck maximal with, then takeck−1 maximal with, and so forth. Finding the numberN, using the formula above, from thek-combination (ck, ...,c2,c1) is also known as "ranking", and the opposite operation (given by the greedy algorithm) as "unranking"; the operations are known by these names in mostcomputer algebra systems, and incomputational mathematics.[2][3]
The term "combinatorial representation of integers" was shortened to "combinatorial number system" byKnuth (2011).[4]He also referencesErnesto Pascal (1887).[5]The term "combinadic" is introduced by James McCaffrey.[6]
Unlike thefactorial number system, the combinatorial number system of degreek is not amixed radix system: the part of the numberN represented by a "digit"ci is not obtained from it by simply multiplying by a place value.
The main application of the combinatorial number system is that it allows rapid computation of thek-combination that is at a given position in the lexicographic ordering, without having to explicitly list thek-combinations preceding it; this allows for instance random generation ofk-combinations of a given set.Enumeration ofk-combinations has many applications, among which aresoftware testing,sampling,quality control, and the analysis oflottery games.
Ak-combination of a setS is asubset ofS withk (distinct) elements. The main purpose of the combinatorial number system is to provide a representation, each by a single number, of all possiblek-combinations of a setS ofn elements. Choosing, for anyn,{0, 1, ...,n − 1} as such a set, it can be arranged that the representation of a givenk-combinationC is independent of the value ofn (althoughn must of course be sufficiently large); in other words consideringC as a subset of a larger set by increasingn will not change the number that represents C. Thus for the combinatorial number system one just considersC as ak-combination of the setN of all natural numbers, without explicitly mentioningn.
In order to ensure that the numbers representing thek-combinations of{0, 1, ...,n − 1} are less than those representingk-combinations not contained in{0, 1, ...,n − 1}, thek-combinations must be ordered in such a way that their largest elements are compared first. The most natural ordering that has this property islexicographic ordering of thedecreasing sequence of their elements. So comparing the 5-combinationsC = {0,3,4,6,9} andC′ = {0,1,3,7,9}, one has thatC comes beforeC′, since they have the same largest part 9, but the next largest part 6 ofC is less than the next largest part 7 ofC′; the sequences compared lexicographically are (9,6,4,3,0) and (9,7,3,1,0).
Another way to describe this ordering is view combinations as describing thek raised bits in thebinary representation of a number, so thatC = {c1, ...,ck} describes the number
(this associates distinct numbers toall finite sets of natural numbers); then comparison ofk-combinations can be done by comparing the associated binary numbers. In the exampleC andC′ correspond to numbers 10010110012 = 60110 and 10100010112 = 65110, which again shows thatC comes beforeC′. This number is not however the one one wants to represent thek-combination with, since many binary numbers have a number of raised bits different fromk; one wants to find the relative position ofC in the ordered list of (only)k-combinations.
The number associated in the combinatorial number system of degreek to ak-combinationC is the number ofk-combinations strictly less thanC in the given ordering. This number can be computed fromC = {ck, ...,c2,c1} withck > ... >c2 >c1 as follows.
From the definition of the ordering it follows that for eachk-combinationS strictly less than C, there is a unique index i such thatci is absent fromS, whileck, ...,ci+1 are present inS, and no other value larger thanci is. One can therefore group thosek-combinationsS according to the possible values 1, 2, ...,k ofi, and count each group separately. For a given value ofi one must includeck, ...,ci+1 inS, and the remainingi elements ofS must be chosen from theci non-negative integers strictly less thanci; moreover any such choice will result in ak-combinationsS strictly less than C. The number of possible choices is, which is therefore the number of combinations in groupi; the total number ofk-combinations strictly less thanC then is
and this is the index (starting from 0) ofC in the ordered list ofk-combinations.
Obviously there is for everyN ∈ N exactly onek-combination at index N in the list (supposingk ≥ 1, since the list is then infinite), so the above argument proves that everyN can be written in exactly one way as a sum ofk binomial coefficients of the given form.
The given formula allows finding the place in the lexicographic ordering of a givenk-combination immediately. The reverse process of finding thek-combination at a given placeN requires somewhat more work, but is straightforward nonetheless. By the definition of the lexicographic ordering, twok-combinations that differ in their largest elementck will be ordered according to the comparison of those largest elements, from which it follows that all combinations with a fixed value of their largest element are contiguous in the list. Moreover the smallest combination withck as the largest element is, and it hasci = i − 1 for alli < k (for this combination all terms in the expression except are zero). Thereforeck is the largest number such that. Ifk > 1 the remaining elements of thek-combination form thek − 1-combination corresponding to the number in the combinatorial number system of degreek − 1, and can therefore be found by continuing in the same way for andk − 1 instead ofN andk.
Suppose one wants to determine the 5-combination at position 72. The successive values of forn = 4, 5, 6, ... are 0, 1, 6, 21, 56, 126, 252, ..., of which the largest one not exceeding 72 is 56, forn = 8. Thereforec5 = 8, and the remaining elements form the4-combination at position72 − 56 = 16. The successive values of forn = 3, 4, 5, ... are 0, 1, 5, 15, 35, ..., of which the largest one not exceeding 16 is 15, forn = 6, soc4 = 6. Continuing similarly to search for a 3-combination at position16 − 15 = 1 one findsc3 = 3, which uses up the final unit; this establishes, and the remaining valuesci will be the maximal ones with, namelyci =i − 1. Thus we have found the 5-combination{8, 6, 3, 1, 0}.
For each of the lottery combinationsc1 < c2 < c3 < c4 < c5 < c6 , there is a list numberN between 0 and which can be found by adding