Jump to content

Combinatorial number system

From Wikipedia, the free encyclopedia

Inmathematics,and in particular incombinatorics,thecombinatorial number systemof degreek(for some positiveintegerk), also referred to ascombinadics,or theMacaulay representation of an integer,is a correspondence betweennatural numbers(taken to include 0)Nandk-combinations.The combinations are represented asstrictly decreasingsequencesck>... >c2>c1≥ 0 where eachcicorresponds 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 thancorrespond to allk-combinationsof{0, 1,...,n− 1}. The correspondence does not depend on the sizenof the set that thek-combinations are taken from, so it can be interpreted as a map fromNto thek-combinations taken fromN;in this view the correspondence is abijection.

The numberNcorresponding to (ck,...,c2,c1) is given by

.

The fact that a unique sequence corresponds to any non-negative numberNwas first observed byD. H. Lehmer.[1]Indeed, agreedy algorithmfinds thek-combination corresponding toN:takeckmaximal with,then takeck−1maximal 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 originally used term "combinatorial representation of integers" was shortened to "combinatorial number system" byKnuth,[4] who also gives a much older reference;[5] the term "combinadic" is introduced by James McCaffrey[6](without reference to previous terminology or work).

Unlike thefactorial number system,the combinatorial number system of degreekis not amixed radixsystem: the partof the numberNrepresented by a "digit"ciis 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-combinationspreceding it; this allows for instance random generation ofk-combinations of a given set.Enumeration ofk-combinationshas many applications, among which aresoftware testing,sampling,quality control,and the analysis oflotterygames.

Ordering combinations

[edit]

Ak-combination of a setSis asubsetofSwithk(distinct) elements. The main purpose of the combinatorial number system is to provide a representation, each by a single number, of allpossiblek-combinations of a setSofnelements. Choosing, for anyn,{0, 1,...,n− 1} as such a set, it can be arranged that the representation of a givenk-combinationCis independent of the value ofn(althoughnmust of course be sufficiently large); in other words consideringCas a subset of a larger set by increasingnwill not change the number that representsC.Thus for the combinatorial number system one just considersCas ak-combination of the setNof 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 orderingof thedecreasingsequence of their elements. So comparing the 5-combinationsC= {0,3,4,6,9} andC′ = {0,1,3,7,9}, one has thatCcomes beforeC′, since they have the same largest part 9, but the next largest part 6 ofCis 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 thekraised bits in thebinary representationof a number, so thatC= {c1,...,ck} describes the number

(this associates distinct numbers toallfinite sets of natural numbers); then comparison ofk-combinations can be done by comparing the associated binary numbers. In the exampleCandC′ correspond to numbers 10010110012= 60110and 10100010112= 65110,which again shows thatCcomes 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 ofCin the ordered list of (only)k-combinations.

Place of a combination in the ordering

[edit]

The number associated in the combinatorial number system of degreekto ak-combinationCis the number ofk-combinations strictly less thanCin the given ordering. This number can be computed fromC= {ck,...,c2,c1} withck>... >c2>c1as follows.

From the definition of the ordering it follows that for eachk-combinationSstrictly less thanC,there is a unique indexisuch thatciis absent fromS,whileck,...,ci+1are present inS,and no other value larger thanciis. One can therefore group thosek-combinationsSaccording to the possible values 1, 2,...,kofi,and count each group separately. For a given value ofione must include ck,...,ci+1inS,and the remainingielements ofSmust be chosen from thecinon-negative integers strictly less thanci;moreover any such choice will result in ak-combinationsSstrictly less thanC.The number of possible choices is,which is therefore the number of combinations in groupi;the total number ofk-combinations strictly less thanCthen is

and this is the index (starting from 0) ofCin the ordered list ofk-combinations.

Obviously there is for everyNNexactly onek-combination at indexNin the list (supposingk≥ 1, since the list is then infinite), so the above argument proves that everyNcan be written in exactly one way as a sum ofkbinomial coefficients of the given form.

Finding thek-combination for a given number

[edit]

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 placeNrequires somewhat more work, but is straightforward nonetheless. By the definition of the lexicographic ordering, twok-combinations that differ in their largest elementckwill 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 withckas the largest element is,and it hasci=i− 1 for alli<k(for this combination all terms in the expression exceptare zero). Thereforeckis the largest number such that.Ifk> 1 the remaining elements of thek-combination form thek− 1-combination corresponding to the numberin the combinatorial number system of degreek− 1,and can therefore be found by continuing in the same way forandk− 1instead ofNandk.

Example

[edit]

Suppose one wants to determine the 5-combination at position 72. The successive values offorn= 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-combinationat position72 − 56 = 16.The successive values offorn= 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 = 1one findsc3= 3, which uses up the final unit; this establishes,and the remaining valuesciwill be the maximal ones with,namelyci=i− 1.Thus we have found the 5-combination{8, 6, 3, 1, 0}.

National Lottery example

[edit]

For each of thelottery combinationsc1<c2<c3<c4<c5<c6,there is a list numberNbetween 0 andwhich can be found by adding

See also

[edit]

References

[edit]
  1. ^Applied Combinatorial Mathematics,Ed. E. F. Beckenbach (1964), pp.27−30.
  2. ^Generating Elementary Combinatorial Objects,Lucia Moura, U. Ottawa, Fall 2009
  3. ^"Combinations — Sage 9.4 Reference Manual: Combinatorics".
  4. ^Knuth, D. E.(2005), "Generating All Combinations and Partitions",The Art of Computer Programming,vol. 4, Fascicle 3, Addison-Wesley, pp. 5−6,ISBN0-201-85394-9.
  5. ^Pascal, Ernesto (1887),Giornale di Matematiche,vol. 25, pp. 45−49
  6. ^McCaffrey, James(2004),Generating the mth Lexicographical Element of a Mathematical Combination,Microsoft Developer Network

Further reading

[edit]