Combinatorial number system
   HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, and in particular in
combinatorics Combinatorics is an area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many a ...
, the combinatorial number system of degree ''k'' (for some positive
integer An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the languag ...
''k''), also referred to as combinadics, or the
Macaulay representation of an integer Given positive integers n and d, the d-th Macaulay representation of n is an expression for n as a sum of binomial coefficients: : n = \binom + \binom + \cdots + \binom + \binom. Here, c_1,\ldots,c_d is a uniquely determined, strictly increasing s ...
, is a correspondence between
natural number In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called '' cardinal ...
s (taken to include 0) ''N'' and ''k''- combinations. The combinations are represented as strictly decreasing sequences ''c''''k'' > ... > ''c''2 > ''c''1 ≥ 0 where each ''ci'' corresponds to the index of a chosen element in a given ''k''-combination. Distinct numbers correspond to distinct ''k''-combinations, and produce them in lexicographic order. The numbers less than \tbinom nk correspond to all of . The correspondence does not depend on the size ''n'' of the set that the ''k''-combinations are taken from, so it can be interpreted as a map from N to the ''k''-combinations taken from N; in this view the correspondence is a
bijection In mathematics, a bijection, also known as a bijective function, one-to-one correspondence, or invertible function, is a function between the elements of two sets, where each element of one set is paired with exactly one element of the other ...
. The number ''N'' corresponding to (''c''''k'', ..., ''c''2, ''c''1) is given by :N=\binomk+\cdots+\binom2+\binom1. The fact that a unique sequence corresponds to any non-negative number ''N'' was first observed by
D. H. Lehmer Derrick Henry "Dick" Lehmer (February 23, 1905 – May 22, 1991), almost always cited as D.H. Lehmer, was an American mathematician significant to the development of computational number theory. Lehmer refined Édouard Lucas' work in the 1930s and ...
. Indeed, a greedy algorithm finds the ''k''-combination corresponding to ''N'': take ''c''''k'' maximal with \tbinomk\leq N, then take ''c''''k''−1 maximal with \tbinom\leq N - \tbinomk, and so forth. Finding the number ''N'', using the formula above, from the ''k''-combination (''c''''k'', ..., ''c''2, ''c''1) is also known as "ranking", and the opposite operation (given by the greedy algorithm) as "unranking"; the operations are known by these names in most
computer algebra system A computer algebra system (CAS) or symbolic algebra system (SAS) is any mathematical software with the ability to manipulate mathematical expressions in a way similar to the traditional manual computations of mathematicians and scientists. The ...
s, and in
computational mathematics Computational mathematics is an area of mathematics devoted to the interaction between mathematics and computer computation.National Science Foundation, Division of Mathematical ScienceProgram description PD 06-888 Computational Mathematics 2006 ...
. The originally used term "combinatorial representation of integers" was shortened to "combinatorial number system" by Knuth, who also gives a much older reference; the term "combinadic" is introduced by James McCaffrey (without reference to previous terminology or work). Unlike the factorial number system, the combinatorial number system of degree ''k'' is not a mixed radix system: the part \tbinomi of the number ''N'' represented by a "digit" ''c''''i'' 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 the ''k''-combination that is at a given position in the lexicographic ordering, without having to explicitly list the preceding it; this allows for instance random generation of ''k''-combinations of a given set. Enumeration of ''k''-combinations has many applications, among which are
software testing Software testing is the act of examining the artifacts and the behavior of the software under test by validation and verification. Software testing can also provide an objective, independent view of the software to allow the business to apprecia ...
, sampling,
quality control Quality control (QC) is a process by which entities review the quality of all factors involved in production. ISO 9000 defines quality control as "a part of quality management focused on fulfilling quality requirements". This approach place ...
, and the analysis of
lottery A lottery is a form of gambling that involves the drawing of numbers at random for a prize. Some governments outlaw lotteries, while others endorse it to the extent of organizing a national or state lottery. It is common to find some degree of ...
games.


Ordering combinations

A ''k''-combination of a set ''S'' is a
subset In mathematics, set ''A'' is a subset of a set ''B'' if all elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they are unequal, then ''A'' is a proper subset of ...
of ''S'' with ''k'' (distinct) elements. The main purpose of the combinatorial number system is to provide a representation, each by a single number, of all \tbinom nk possible ''k''-combinations of a set ''S'' of ''n'' elements. Choosing, for any ''n'', as such a set, it can be arranged that the representation of a given ''k''-combination ''C'' is independent of the value of ''n'' (although ''n'' must of course be sufficiently large); in other words considering ''C'' as a subset of a larger set by increasing ''n'' will not change the number that represents ''C''. Thus for the combinatorial number system one just considers ''C'' as a ''k''-combination of the set N of all natural numbers, without explicitly mentioning ''n''. In order to ensure that the numbers representing the ''k''-combinations of are less than those representing ''k''-combinations not contained in , the ''k''-combinations must be ordered in such a way that their largest elements are compared first. The most natural ordering that has this property is lexicographic ordering of the ''decreasing'' sequence of their elements. So comparing the 5-combinations ''C'' =  and ''C''′ = , one has that ''C'' comes before ''C''′, since they have the same largest part 9, but the next largest part 6 of ''C'' is less than the next largest part 7 of ''C''′; 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 the ''k'' raised bits in the binary representation of a number, so that ''C'' =  describes the number :2^+2^+\cdots+2^ (this associates distinct numbers to ''all'' finite sets of natural numbers); then comparison of ''k''-combinations can be done by comparing the associated binary numbers. In the example ''C'' and ''C''′ correspond to numbers 10010110012 = 60110 and 10100010112 = 65110, which again shows that ''C'' comes before ''C''′. This number is not however the one one wants to represent the ''k''-combination with, since many binary numbers have a number of raised bits different from ''k''; one wants to find the relative position of ''C'' in the ordered list of (only) .


Place of a combination in the ordering

The number associated in the combinatorial number system of degree ''k'' to a ''k''-combination ''C'' is the number of ''k''-combinations strictly less than ''C'' in the given ordering. This number can be computed from ''C'' =  with ''c''''k'' > ... > ''c''2 > ''c''1 as follows. From the definition of the ordering it follows that for each ''k''-combination ''S'' strictly less than ''C'', there is a unique index ''i'' such that ''c''''i'' is absent from ''S'', while ''c''''k'', ..., ''c''''i''+1 are present in ''S'', and no other value larger than ''c''''i'' is. One can therefore group those ''S'' according to the possible values 1, 2, ..., ''k'' of ''i'', and count each group separately. For a given value of ''i'' one must include ''c''''k'', ..., ''c''''i''+1 in ''S'', and the remaining ''i'' elements of ''S'' must be chosen from the ''c''''i'' non-negative integers strictly less than ''c''''i''; moreover any such choice will result in a ''S'' strictly less than ''C''. The number of possible choices is \tbinomi, which is therefore the number of combinations in group ''i''; the total number of ''k''-combinations strictly less than ''C'' then is :\binom1+\binom2+\cdots+\binomk, and this is the index (starting from 0) of ''C'' in the ordered list of ''k''-combinations. Obviously there is for every ''N'' ∈ N exactly one ''k''-combination at index ''N'' in the list (supposing ''k'' ≥ 1, since the list is then infinite), so the above argument proves that every ''N'' can be written in exactly one way as a sum of ''k'' binomial coefficients of the given form.


Finding the ''k''-combination for a given number

The given formula allows finding the place in the lexicographic ordering of a given ''k''-combination immediately. The reverse process of finding the ''k''-combination at a given place ''N'' requires somewhat more work, but is straightforward nonetheless. By the definition of the lexicographic ordering, two ''k''-combinations that differ in their largest element ''c''''k'' 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 with ''c''''k'' as the largest element is \tbinomk, and it has ''c''''i'' = ''i'' − 1 for all ''i'' < ''k'' (for this combination all terms in the expression except \tbinomk are zero). Therefore ''c''''k'' is the largest number such that \tbinomk\leq N. If ''k'' > 1 the remaining elements of the ''k''-combination form the -combination corresponding to the number N-\tbinomk in the combinatorial number system of degree , and can therefore be found by continuing in the same way for N-\tbinomk and instead of ''N'' and ''k''.


Example

Suppose one wants to determine the 5-combination at position 72. The successive values of \tbinom n5 for ''n'' = 4, 5, 6, ... are 0, 1, 6, 21, 56, 126, 252, ..., of which the largest one not exceeding 72 is 56, for ''n'' = 8. Therefore ''c''5 = 8, and the remaining elements form the at position . The successive values of \tbinom n4 for ''n'' = 3, 4, 5, ... are 0, 1, 5, 15, 35, ..., of which the largest one not exceeding 16 is 15, for ''n'' = 6, so ''c''4 = 6. Continuing similarly to search for a 3-combination at position one finds ''c''3 = 3, which uses up the final unit; this establishes 72=\tbinom85+\tbinom64+\tbinom33, and the remaining values ''c''''i'' will be the maximal ones with \tbinomi=0, namely . Thus we have found the 5-combination .


National Lottery example

For each of the \binom6 lottery combinations ''c''1 < ''c''2 < ''c''3 < ''c''4 < ''c''5 < ''c''6 , there is a list number ''N'' between 0 and \binom6 - 1 which can be found by adding : \binom 6 + \binom 5 + \binom 4 + \binom 3 + \binom 2 + \binom{49-c_6} 1.


See also

* Factorial number system (also called factoradics) * Primorial number system * Asymmetric numeral systems - also e.g. of combination to natural number, widely used in data compression


References

Combinatorics Factorial and binomial topics