Content deleted Content added
Rescuing 0 sources and tagging 1 as dead. #IABot (v1.6.1) |
Adding short description: "Scheme for numbering permutations" |
||
(23 intermediate revisions by 17 users not shown) | |||
Line 1:
{{Short description|Scheme for numbering permutations}}
In [[mathematics]] and in particular in [[combinatorics]], the '''Lehmer code''' is a particular way to [[encoding|encode]] each possible [[permutation]] of a sequence of ''n'' numbers. It is an instance of a scheme for [[Permutation#Numbering permutations|numbering permutations]] and is an example of an
The Lehmer code is named in reference to [[
==The code==
The Lehmer code makes use of the fact that there are
:<math>n!=n\times(n-1)\times\cdots\times2\times1</math>
permutations of a sequence of ''n'' numbers. If a permutation ''σ'' is specified by the sequence (''σ''<sub>1</sub>,
:<math>L(\sigma)=(L(\sigma)_1,\ldots,L(\sigma)_n)\quad\text{where}\quad L(\sigma)_i=\#\{ j>i : \sigma_j<\sigma_i \},</math>
in other words the term ''L''(''σ'')<sub>''i''</sub> counts the number of terms in (''σ''<sub>1</sub>,
A pair of indices (''i'',''j'') with {{math|''i'' < ''j''}} and {{math|''σ
at position ''i'' similarly signifies a right-to-left maximum, and that the Lehmer code of ''σ'' coincides with the [[factorial number system]] representation of its position in the list of permutations of ''n'' in lexicographical order (numbering the positions starting from 0).
Variations of this encoding can be obtained by counting inversions (''i'',''j'') for fixed ''j'' rather than fixed ''i'', by counting inversions with a fixed smaller ''value'' {{math|''σ
==Encoding and decoding==
The usual way to prove that there are ''n''! different permutations of ''n'' objects is to observe that the first object can be chosen in {{math|''n''}} different ways, the next object in {{math|''n'' − 1}} different ways (because choosing the same number as the first is forbidden), the next in {{math|''n'' − 2}} different ways (because there are now 2 forbidden values), and so forth. Translating this freedom of choice at each step into a number, one obtains an encoding algorithm, one that finds the Lehmer code of a given permutation. One need not suppose the objects permuted to be numbers, but one needs a [[total ordering]] of the set of objects. Since the code numbers are to start from 0, the appropriate number to encode each object ''σ
This number to encode each object can be found by direct counting, in several ways (directly counting inversions, or correcting the total number of objects smaller than a given one, which is its sequence number starting from 0 in the set, by those that are unavailable at its position). Another method which is in-place, but not really more efficient, is to start with the permutation of {0, 1,
:<math> \begin{matrix}
\mathbf1&5&0&6&3&4&2\\
Line 32 ⟶ 33:
where the final line is the Lehmer code (at each line one subtracts 1 from the larger entries to the right of the boldface element to form the next line).
For decoding a Lehmer code into a permutation of a given set, the latter procedure may be reversed: for each entry ''x'', in order from right to left, correct the items to its right by adding 1 to all those (currently) greater than or equal to ''x''; finally interpret the resulting permutation of {0, 1,
==Applications to combinatorics and probabilities==
Line 38 ⟶ 39:
=== Independence of relative ranks ===
The Lehmer code defines a bijection from the [[symmetric group]] ''S
=== Number of right-to-left minima and maxima ===
Line 44 ⟶ 45:
Let ''B(k)'' (resp. ''H(k)'') be the event "there is right-to-left minimum (resp. maximum) at rank ''k''", i.e. ''B(k)'' is the set of the permutations <math>\scriptstyle\ \mathfrak{S}_n</math> which exhibit a right-to-left minimum (resp. maximum) at rank ''k''. We clearly have
<div class="center"><math>\{\omega\in B(k)\}\Leftrightarrow\{L(k,\omega)=0\}\quad\text{and}\quad\{\omega\in H(k)\}\Leftrightarrow\{L(k,\omega)=k-1\}.</math></
Thus the number ''N<sub>b</sub>(ω)'' (resp. ''N<sub>h</sub>(ω)'') of right-to-left minimum (resp. maximum) for the permutation ''ω'' can be written as a sum of independent [[Bernoulli random variable]]s each with a respective parameter of 1/k :
<div class="center"><math>N_b(\omega)=\sum_{1\le k\le n}\ 1\!\!1_{B(k)}\quad\text{and}\quad N_b(\omega)=\sum_{1\le k\le n}\ 1\!\!1_{H(k)}.</math></
Indeed, as ''L(k)'' follows the uniform law on <math>\scriptstyle\ [\![1,k]\!],</math>
<div class="center"><math>\mathbb{P}(B(k))=\mathbb{P}(L(k)=0)=\mathbb{P}(H(k))=\mathbb{P}(L(k)=k-1)=\tfrac1k.</math></
The [[generating function]] for the Bernoulli random variable <math>1\!\!1_{B(k)}</math> is
<div class="center"><math>G_k(s)=\frac{k-1+s}k,</math></
therefore the generating function of ''N<sub>b</sub>'' is
<div class="center"><math>G(s)=\prod_{k=1}^nG_k(s)\ =\ \frac{
(using the [[Falling and rising factorials|rising factorial]] notation),
which allows us to recover the product formula for the generating function of the
[[Stirling numbers of the first kind]] (unsigned).
===The secretary problem===
Line 61 ⟶ 64:
This is an optimal stop problem, a classic in decision theory, statistics and applied probabilities, where a random permutation is gradually revealed through the first elements of its Lehmer code, and where the goal is to stop exactly at the element k such as σ(k)=n, whereas the only available information (the k first values of the Lehmer code) is not sufficient to compute σ(k).
In less mathematical words
The interviewer thus knows the rank of the k<sup>th</sup> applicant, therefore, at the moment of making his k<sup>th</sup> decision, the interviewer knows only the k first elements of the Lehmer code whereas he would need to know all of them to make a well informed decision.
To determine the optimal strategies (i.e. the strategy maximizing the probability of a win), the statistical properties of the Lehmer code are crucial.
Allegedly, [[Johannes Kepler]] clearly exposed this [[secretary problem]] to a friend of his at a time when he was trying to make up his mind and choose one out eleven prospective brides as his second wife. His first marriage had been an unhappy one, having been arranged without himself being consulted, and he was thus very concerned that he could reach the right decision.<ref name="ferguson"/
==
Several related constructions have also been put into use. One of them is often called inversion vector, e.g. by [[Wolfram Alpha]].
See also {{Section link|Inversion_(discrete_mathematics)|Inversion related vectors}}.
{{Portal|Mathematics}}
==References==
{{Reflist|refs=
<ref name="lehmer">
{{Citation
| last=Lehmer
| first=D.H.
| title=Combinatorial Analysis
| chapter=Teaching combinatorial tricks to a computer | series=Proceedings of Symposia in Applied Mathematics
| author-link=D. H. Lehmer
| volume=10
| year=1960
| pages=179–193
| doi=10.1090/psapm/010/0113289
| isbn=978-0-8218-1310-2
| mr=0113289
}}
</ref>
Line 93 ⟶ 101:
| last=Laisant
| first=Charles-Ange
| author-link= Charles-Ange Laisant
| title=Sur la numération factorielle, application aux permutations
| trans-title=On factorial numbering, application to permutations
| journal=Bulletin de la Société Mathématique de France
| volume=16
| issue=<!--1 of 1-->
| year=1888
| pages=176–183
| url=http://www.numdam.org/item?id=BSMF_1888__16__176_0
| doi=10.24033/bsmf.378
}}
</ref>
Line 105 ⟶ 116:
<ref name="ferguson">{{Citation
| last=Ferguson
| first=Thomas S.|authorlink= Thomas S. Ferguson
| title=Who solved the secretary problem
| journal=Statistical Science
| volume=4
| issue=3
|
| pages=282–289
| jstor=2245639
| doi=10.1214/ss/1177012493
| doi-access=free
| url=https://www2.math.upenn.edu/~ted/210F10/References/Secretary.pdf
}}
</ref>
Line 121 ⟶ 134:
==Bibliography==
*{{Citation
|
|
|last2 = Rakotondrajao
|first2 = Fanja
|title = A permutation representation that knows what "Eulerian" means
|journal = Discrete Mathematics and Theoretical Computer Science
Line 129 ⟶ 144:
|pages = 101–108
|url = http://www.dmtcs.org/volumes/abstracts/pspapers/dm040203.ps
|archive-url = https://web.archive.org/web/20041116061630/http://www.dmtcs.org/volumes/abstracts/pspapers/dm040203.ps
|url-status = dead
|archive-date = 2004-11-16
}}
*{{ Citation
| last1=Knuth
| first1=
| author-link=Donald Knuth
| title=The
| volume=3
| publisher=Addison-Wesley
|