HOME

TheInfoList



OR:

The statistics of random permutations, such as the cycle structure of a
random permutation A random permutation is a random ordering of a set of objects, that is, a permutation-valued random variable. The use of random permutations is often fundamental to fields that use randomized algorithms such as coding theory, cryptography, and sim ...
are of fundamental importance in the
analysis of algorithms In computer science, the analysis of algorithms is the process of finding the computational complexity of algorithms—the amount of time, storage, or other resources needed to execute them. Usually, this involves determining a function that re ...
, especially of sorting algorithms, which operate on random permutations. Suppose, for example, that we are using
quickselect In computer science, quickselect is a selection algorithm to find the ''k''th smallest element in an unordered list. It is also known as the kth order statistics . It is related to the quicksort sorting algorithm. Like quicksort, it was devel ...
(a cousin of
quicksort Quicksort is an efficient, general-purpose sorting algorithm. Quicksort was developed by British computer scientist Tony Hoare in 1959 and published in 1961, it is still a commonly used algorithm for sorting. Overall, it is slightly faster than ...
) to select a random element of a random permutation. Quickselect will perform a partial sort on the array, as it partitions the array according to the pivot. Hence a permutation will be less disordered after quickselect has been performed. The amount of disorder that remains may be analysed with generating functions. These generating functions depend in a fundamental way on the generating functions of random permutation statistics. Hence it is of vital importance to compute these generating functions. The article on
random permutation A random permutation is a random ordering of a set of objects, that is, a permutation-valued random variable. The use of random permutations is often fundamental to fields that use randomized algorithms such as coding theory, cryptography, and sim ...
s contains an introduction to random permutations.


The fundamental relation

Permutations are sets of labelled cycles. Using the labelled case of the
Flajolet–Sedgewick fundamental theorem In combinatorics, the symbolic method is a technique for counting combinatorial objects. It uses the internal structure of the objects to derive formulas for their generating functions. The method is mostly associated with Philippe Flajolet and ...
and writing \scriptstyle\mathcal for the set of permutations and \scriptstyle\mathcal for the singleton set, we have : \operatorname(\operatorname(\mathcal)) = \mathcal. Translating into
exponential generating function In mathematics, a generating function is a way of encoding an infinite sequence of numbers () by treating them as the coefficients of a formal power series. This series is called the generating function of the sequence. Unlike an ordinary ser ...
s (EGFs), we have : \exp \left(\log \frac\right) = \frac where we have used the fact that the EGF of the
combinatorial species In combinatorial mathematics, the theory of combinatorial species is an abstract, systematic method for deriving the generating functions of discrete structures, which allows one to not merely count these structures but give bijective proofs invol ...
of permutations (there are ''n''! permutations of ''n'' elements) is : \sum_ \frac z^n = \frac. This one equation allows one to derive a large number of permutation statistics. Firstly, by dropping terms from \scriptstyle\operatorname, i.e. exp, we may constrain the ''number of cycles'' that a permutation contains, e.g. by restricting the EGF to \scriptstyle\operatorname_2 we obtain permutations containing two cycles. Secondly, note that the EGF of labelled cycles, i.e. of \scriptstyle\operatorname(\mathcal), is \sum_ \frac = \sum_ \frac = \log \frac because there are ''k''! / ''k'' labelled cycles. This means that by dropping terms from this generating function, we may constrain the ''size of the cycles'' that occur in a permutation and obtain an EGF of the permutations containing only cycles of a given size. Instead of removing and selecting cycles, one can also put different weights on different size cycles. If b: \mathbb \rightarrow \mathbb is a weight function that depends only on the size ''k'' of the cycle and for brevity we write :b(\sigma) = \sum_ b(c), defining the value of ''b'' for a permutation \sigma to be the sum of its values on the cycles, then we may mark cycles of length ''k'' with ''u''''b''(''k'') and obtain a two-variable generating function : g(z, u) = 1 + \sum_ \left( \sum_ u^ \right) \frac = \exp \sum_ u^ \frac This is a "mixed" generating function: it is an exponential generating function in ''z'' and an
ordinary generating function In mathematics, a generating function is a way of encoding an infinite sequence of numbers () by treating them as the coefficients of a formal power series. This series is called the generating function of the sequence. Unlike an ordinary series ...
in the secondary parameter ''u.'' Differentiating and evaluating at ''u'' = 1, we have : \frac g(z, u) \Bigg, _ = \frac \sum_ b(k) \frac = \sum_ \left( \sum_ b(\sigma) \right) \frac This is the
probability generating function In probability theory, the probability generating function of a discrete random variable is a power series representation (the generating function) of the probability mass function of the random variable. Probability generating functions are often ...
of the expectation of ''b''. In other words, the coefficient of z^n in this power series is the expected value of ''b'' on permutations in S_n, given that each permutation is chosen with the same probability 1/n!. This article uses the coefficient extraction operator 'z''''n'' documented on the page for
formal power series In mathematics, a formal series is an infinite sum that is considered independently from any notion of convergence, and can be manipulated with the usual algebraic operations on series (addition, subtraction, multiplication, division, partial sum ...
.


Number of permutations that are involutions

An
involution Involution may refer to: * Involute, a construction in the differential geometry of curves * '' Agricultural Involution: The Processes of Ecological Change in Indonesia'', a 1963 study of intensification of production through increased labour inpu ...
is a permutation σ so that σ2 = 1 under permutation composition. It follows that σ may only contain cycles of length one or two, i.e. the
exponential generating function In mathematics, a generating function is a way of encoding an infinite sequence of numbers () by treating them as the coefficients of a formal power series. This series is called the generating function of the sequence. Unlike an ordinary ser ...
''g''(''z'') of these permutations is :g(z) = \exp\left(z + \frac z^2\right). This gives the explicit formula for the total number I(n) of involutions among the permutations σ ∈ ''S''''n'': : I(n) = n! ^ng(z) = n! \sum_ \frac = n! \sum_^ \frac. Dividing by ''n''! yields the probability that a random permutation is an involution. These numbers are known as
telephone number A telephone number is a sequence of digits assigned to a landline telephone subscriber station connected to a telephone line or to a wireless electronic telephony device, such as a radio telephone or a mobile telephone, or to other devices f ...
s.


Number of permutations that are ''m''th roots of unity

This generalizes the concept of an involution. An ''m''th root of unity is a permutation σ so that σ''m'' = 1 under permutation composition. Now every time we apply σ we move one step in parallel along all of its cycles. A cycle of length ''d'' applied ''d'' times produces the identity permutation on ''d'' elements (''d'' fixed points) and ''d'' is the smallest value to do so. Hence ''m'' must be a multiple of all cycle sizes ''d'', i.e. the only possible cycles are those whose length ''d'' is a divisor of ''m''. It follows that the EGF ''g''(''x'') of these permutations is :g(z) = \exp\left(\sum_ \frac\right). When ''m'' = ''p'', where ''p'' is prime, this simplifies to : n! ^ng(z) = n! \sum_ \frac = n! \sum_^ \frac.


Number of permutations of order exactly ''k''

This one can be done by
Möbius inversion Moebius, Möbius or Mobius may refer to: People * August Ferdinand Möbius (1790–1868), German mathematician and astronomer * Theodor Möbius (1821–1890), German philologist * Karl Möbius (1825–1908), German zoologist and ecologist * Paul ...
. Working with the same concept as in the previous entry we note that the combinatorial species \mathcal of permutations whose order divides ''k'' is given by :\mathcal = \operatorname\left(\sum_ \operatorname_(\mathcal)\right). Translation to exponential generating functions we obtain the EGF of permutations whose order divides ''k'', which is :Q_k(z) = \exp\left(\sum_ \frac\right). Now we can use this generating function to count permutations of order exactly ''k''. Let p_ be the number of permutations on ''n'' whose order is exactly ''d'' and q_ the number of permutations on ''n'' the permutation count whose order divides ''k''. Then we have : \sum_ p_ = q_. It follows by
Möbius inversion Moebius, Möbius or Mobius may refer to: People * August Ferdinand Möbius (1790–1868), German mathematician and astronomer * Theodor Möbius (1821–1890), German philologist * Karl Möbius (1825–1908), German zoologist and ecologist * Paul ...
that : \sum_ q_\times \mu(k/d) = p_. Therefore, we have the EGF :Q(z) = \sum_ \mu(k/d) \times Q_d(z) = \sum_ \mu(k/d) \exp\left(\sum_ \frac\right). The desired count is then given by :n! ^nQ(z). This formula produces e.g. for ''k'' = 6 the EGF :Q(z) = ^z - ^ - ^ + ^ with the sequence of values starting at ''n'' = 5 :20, 240, 1470, 10640, 83160, 584640, 4496030, 42658440, 371762820, 3594871280,\ldots For ''k'' = 8 we get the EGF :Q(z) = -^+ ^ with the sequence of values starting at ''n'' = 8 :5040, 45360, 453600, 3326400, 39916800, 363242880, 3874590720, 34767532800,\ldots Finally for ''k'' = 12 we get the EGF :Q(z) = ^-^-^ + ^ with the sequence of values starting at ''n'' = 7 :420, 3360, 30240, 403200, 4019400, 80166240, 965284320, 12173441280, 162850287600,\ldots


Number of permutations that are derangements

Suppose there are ''n'' people at a party, each of whom brought an umbrella. At the end of the party everyone picks an umbrella out of the stack of umbrellas and leaves. What is the probability that no one left with his/her own umbrella? This problem is equivalent to counting permutations with no fixed points (called
derangement In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears in its original position. In other words, a derangement is a permutation that has no fixed points. The number of derangements of ...
s), and hence the EGF, where we subtract out fixed points (cycles of length 1) by removing the term ''z'' from the fundamental relation is :\exp \left( -z + \sum_ \frac k \right) = \frac. Multiplication by 1/(1-z) sums the coefficients of e^, so D(n), the total number of derangements, is given by: : D(n) = n! \sum_^n \frac \; \approx \; \frac. Hence there are about n!/e derangements and the probability that a random permutation is a derangement is 1/e. This result may also be proved by inclusion–exclusion. Using the sets A_p where \begin1\le p\le n\end to denote the set of permutations that fix ''p'', we have : \left, \bigcup_p A_p \ = \sum_p \left, A_p \ \; - \; \sum_ \left, A_p \cap A_q \ \; + \; \sum_ \left, A_p \cap A_q \cap A_r \ \; - \; \cdots \; \pm \; \left, A_p \cap \; \cdots \; \cap A_s \. This formula counts the number of permutations that have at least one fixed point. The cardinalities are as follows: : \left, A_p \ = (n-1)!\; , \; \; \left, A_p \cap A_q \ = (n-2)!\; , \; \; \left, A_p \cap A_q \cap A_r \ = (n-3)!\; , \; \ldots Hence the number of permutations with no fixed point is : n! \; \; - \; \; (n-1)! \; \; + \; \; (n-2)! \; \; - \; \; (n-3)! \; \; + \; \; \cdots \; \; \pm \; \; (n-n)! or : n! \left( 1 - \frac + \frac - \frac + \cdots \pm \frac \right) = n! \sum_^n \frac and we have the claim. There is a generalization of these numbers, which is known as
rencontres numbers In combinatorial mathematics, the rencontres numbers are a triangular array of integers that enumerate permutations of the set with specified numbers of fixed points: in other words, partial derangements. (''Rencontre'' is French for ''encounte ...
, i.e. the number D(n, m) of permutations of /math> containing ''m'' fixed points. The corresponding EGF is obtained by marking cycles of size one with the variable ''u'', i.e. choosing ''b''(''k'') equal to one for k=1 and zero otherwise, which yields the generating function g(z, u) of the set of permutations by the number of fixed points: : g(z, u) = \exp \left( -z + uz + \sum_ \frac \right) = \frac e^. It follows that : ^mg(z, u) = \frac \frac and hence : D(n, m) = n! ^n ^mg(z, u) = \frac ^\frac = \frac \sum_^ \frac. This immediately implies that : D(n, m) = D(n-m, 0) \; \; \text \; \; \frac \approx \frac for ''n'' large, ''m'' fixed.


Order of a random permutation

If ''P'' is a permutation, the ''order'' of ''P'' is the smallest positive integer ''n'' for which P^n is the identity permutation. This is the least common multiple of the lengths of the cycles of ''P''. A theorem of Goh and SchmutzAlt URL
/ref> states that if \mu_n is the expected order of a random permutation of size ''n'', then :\log\mu_n \sim c\sqrt where the constant ''c'' is : 2\sqrt\approx 1.1178641511899


Derangements containing an even and an odd number of cycles

We can use the same construction as in the previous section to compute the number of derangements D_0(n) containing an even number of cycles and the number D_1(n) containing an odd number of cycles. To do this we need to mark all cycles and subtract fixed points, giving : g(z, u) = \exp\left( - u z + u \log \frac \right) = \exp(-uz) \left( \frac \right)^u. Now some very basic reasoning shows that the EGF q(z) of D_0(n) is given by : q(z) = \frac \times g(z, -1) + \frac \times g(z, 1) = \frac \exp(-z) \frac +\frac \exp(z) (1-z). We thus have :D_0(n) = n! ^nq(z) = \frac n! \sum_^n \frac + \frac n! \frac - \frac n! \frac which is :\frac n! \sum_^n \frac + \frac (1-n) \sim \frac n! + \frac (1-n). Subtracting D_0(n) from D(n), we find :D_1(n) = \frac n! \sum_^n \frac - \frac (1-n). The difference of these two (D_0(n) and D_1(n)) is n-1.


One hundred prisoners

A prison warden wants to make room in his prison and is considering liberating one hundred prisoners, thereby freeing one hundred cells. He therefore assembles one hundred prisoners and asks them to play the following game: he lines up one hundred urns in a row, each containing the name of one prisoner, where every prisoner's name occurs exactly once. The game is played as follows: every prisoner is allowed to look inside fifty urns. If he or she does not find his or her name in one of the fifty urns, all prisoners will immediately be executed, otherwise the game continues. The prisoners have a few moments to decide on a strategy, knowing that once the game has begun, they will not be able to communicate with each other, mark the urns in any way or move the urns or the names inside them. Choosing urns at random, their chances of survival are almost zero, but there is a strategy giving them a 30% chance of survival, assuming that the names are assigned to urns randomly – what is it? First of all, the survival probability using random choices is : \left( \frac \right)^ = \frac, so this is definitely not a practical strategy. The 30% survival strategy is to consider the contents of the urns to be a permutation of the prisoners, and traverse cycles. To keep the notation simple, assign a number to each prisoner, for example by sorting their names alphabetically. The urns may thereafter be considered to contain numbers rather than names. Now clearly the contents of the urns define a permutation. The first prisoner opens the first urn. If he finds his name, he has finished and survives. Otherwise he opens the urn with the number he found in the first urn. The process repeats: the prisoner opens an urn and survives if he finds his name, otherwise he opens the urn with the number just retrieved, up to a limit of fifty urns. The second prisoner starts with urn number two, the third with urn number three, and so on. This strategy is precisely equivalent to a traversal of the cycles of the permutation represented by the urns. Every prisoner starts with the urn bearing his number and keeps on traversing his cycle up to a limit of fifty urns. The number of the urn that contains his number is the pre-image of that number under the permutation. Hence the prisoners survive if all cycles of the permutation contain at most fifty elements. We have to show that this probability is at least 30%. Note that this assumes that the warden chooses the permutation randomly; if the warden anticipates this strategy, he can simply choose a permutation with a cycle of length 51. To overcome this, the prisoners may agree in advance on a random permutation of their names. We consider the general case of 2n prisoners and n urns being opened. We first calculate the complementary probability, i.e. that there is a cycle of more than n elements. With this in mind, we introduce : g(z, u) = \exp \left( z + \frac + \frac + \cdots + u \frac + u \frac + \cdots \right) or : \frac \exp \left( (u-1) \left( \frac + \frac + \cdots \right) \right), so that the desired probability is : ^u] g(z, u), because the cycle of more than n elements will necessarily be unique. Using the fact that 2(n+1)>2n, we find that : ^u] g(z, u) = ^u] \frac \left( 1 + (u-1) \left( \frac + \frac + \cdots \right) \right), which yields : ^u] g(z, u) = ^\frac \left( \frac + \frac + \cdots \right) = \sum_^ \frac = H_ - H_n. Finally, using an integral estimate such as Euler–Maclaurin summation, or the asymptotic expansion of the ''n''th
harmonic number In mathematics, the -th harmonic number is the sum of the reciprocals of the first natural numbers: H_n= 1+\frac+\frac+\cdots+\frac =\sum_^n \frac. Starting from , the sequence of harmonic numbers begins: 1, \frac, \frac, \frac, \frac, \dot ...
, we obtain : H_ - H_n \sim \log 2 - \frac + \frac - \frac + \frac - \frac + \cdots, so that : ^u] g(z, u) < \log 2 \quad \mbox \quad 1 - ^u] g(z, u) > 1 - \log 2 = 0.30685281, or at least 30%, as claimed. A related result is that asymptotically, the expected length of the longest cycle is ''λn,'' where λ is the
Golomb–Dickman constant In mathematics, the Golomb–Dickman constant arises in the theory of random permutations and in number theory. Its value is :\lambda = 0.62432 99885 43550 87099 29363 83100 83724\dots It is not known whether this constant is rational or irration ...
, approximately 0.62. This example is due to Anna Gál and Peter Bro Miltersen; consult the paper by Peter Winkler for more information, and see the discussion on ''Les-Mathematiques.net''. Consult the references on 100 prisoners for links to these references. The above computation may be performed in a more simple and direct way, as follows: first note that a permutation of 2n elements contains at most one cycle of length strictly greater than n . Thus, if we denote :p_k=\Pr mboxk then :\Pr mbox> n= \sum_^ p_k. For k>n, the number of permutations that contain a cycle of length exactly k is : \cdot \frac \cdot (2n-k)!. Explanation: is the number of ways of choosing the k elements that comprise the cycle; \frac is the number of ways of arranging k items in a cycle; and (2n-k)! is the number of ways to permute the remaining elements. There is no double counting here because there is at most one cycle of length k when k > n. Thus, :p_k = \frac = \frac1k. We conclude that :\Pr mbox> n= \sum_^ \frac1k = H_-H_n.


A variation on the 100 prisoners problem (keys and boxes)

There is a closely related problem that fits the method presented here quite nicely. Say you have ''n'' ordered boxes. Every box contains a key to some other box or possibly itself giving a permutation of the keys. You are allowed to select ''k'' of these ''n'' boxes all at once and break them open simultaneously, gaining access to ''k'' keys. What is the probability that using these keys you can open all ''n'' boxes, where you use a found key to open the box it belongs to and repeat. The mathematical statement of this problem is as follows: pick a random permutation on ''n'' elements and ''k'' values from the range ''1'' to ''n'', also at random, call these marks. What is the probability that there is at least one mark on every cycle of the permutation? The claim is this probability is ''k/n''. The species \mathcal of permutations by cycles with some non-empty subset of every cycle being marked has the specification :\mathcal = \operatorname \left(\sum_\operatorname_(\mathcal) \times \sum_^q \mathcal^p \right). The index in the inner sum starts at one because we must have at least one mark on every cycle. Translating the specification to generating functions we obtain the bivariate generating function :G(z, u) = \exp\left(\sum_ \frac \sum_^q u^p\right). This simplifies to :\exp\left(\sum_ \frac (u+1)^q - \sum_ \frac \right) or :\exp\left(\log\frac - \log\frac\right) = \frac. In order to extract coefficients from this re-write like so :(1-z)\sum_ (u+1)^q z^q. It now follows that : ^nG(z, u) = (u+1)^n - (u+1)^ and hence : ^k ^nG(z, u) = - . Divide by to obtain :1 - \frac \frac = 1 - \frac = \frac. We do not need to divide by ''n!'' because G(z, u) is exponential in ''z''.


Number of permutations containing ''m'' cycles

Applying the
Flajolet–Sedgewick fundamental theorem In combinatorics, the symbolic method is a technique for counting combinatorial objects. It uses the internal structure of the objects to derive formulas for their generating functions. The method is mostly associated with Philippe Flajolet and ...
, i.e. the labelled enumeration theorem with G = S_m, to the set :\operatorname_(\operatorname(\mathcal)) we obtain the generating function : g_m(z) = \frac \left( \log \frac \right)^m = \frac \left( \log \frac \right)^m. The term : (-1)^ n! \; ^ng_m(z) = s(n,m) yields the signed
Stirling numbers of the first kind In mathematics, especially in combinatorics, Stirling numbers of the first kind arise in the study of permutations. In particular, the Stirling numbers of the first kind count permutations according to their number of cycles (counting fixed poin ...
, and g_m(z) is the EGF of the unsigned Stirling numbers of the first kind, i.e. : n! ^ng_m(z) = \left begin n \\ m \end\right We can compute the OGF of the signed Stirling numbers for ''n'' fixed, i.e. : s_n(w) = \sum_^n s(n,m) w^m. Start with : g_m(z) = \sum_ \frac s(n,m) z^n which yields : (-1)^m g_m(z) w^m = \sum_ \frac s(n,m) w^m z^n. Summing this, we obtain : \sum_ (-1)^m g_m(z) w^m = \sum_ \sum_ \frac s(n,m) w^m z^n = \sum_\frac z^n \sum_^n s(n,m) w^m. Using the formula involving the logarithm for g_m(z) on the left, the definition of s_n(w) on the right, and the
binomial theorem In elementary algebra, the binomial theorem (or binomial expansion) describes the algebraic expansion of powers of a binomial. According to the theorem, it is possible to expand the polynomial into a sum involving terms of the form , where the ...
, we obtain : (1-z)^w = \sum_ (-1)^n z^n = \sum_\frac s_n(w) z^n. Comparing the coefficients of z^n, and using the definition of the
binomial coefficient In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is indexed by a pair of integers and is written \tbinom. It is the coefficient of the t ...
, we finally have : s_n(w) = w \; (w-1) \; (w-2) \; \cdots \; (w-(n-1)) = (w)_n, a
falling factorial In mathematics, the falling factorial (sometimes called the descending factorial, falling sequential product, or lower factorial) is defined as the polynomial :\begin (x)_n = x^\underline &= \overbrace^ \\ &= \prod_^n(x-k+1) = \prod_^(x-k) \,. \e ...
. The computation of the OGF of the unsigned Stirling numbers of the first kind works in a similar way.


Expected number of cycles of a given size ''m''

In this problem we use a bivariate generating function ''g''(''z'', ''u'') as described in the introduction. The value of ''b'' for a cycle not of size ''m'' is zero, and one for a cycle of size ''m''. We have : \frac g(z, u) \Bigg, _ = \frac \sum_ b(k) \frac = \frac \frac or : \frac z^m \; + \; \frac z^ \; + \; \frac z^ \; + \; \cdots This means that the expected number of cycles of size ''m'' in a permutation of length ''n'' less than ''m'' is zero (obviously). A random permutation of length at least ''m'' contains on average 1/''m'' cycles of length ''m''. In particular, a random permutation contains about one fixed point. The OGF of the expected number of cycles of length less than or equal to ''m'' is therefore : \frac \sum_^m \frac \mbox ^n\frac \sum_^m \frac = H_m \mbox n \ge m where ''H''''m'' is the ''m''th
harmonic number In mathematics, the -th harmonic number is the sum of the reciprocals of the first natural numbers: H_n= 1+\frac+\frac+\cdots+\frac =\sum_^n \frac. Starting from , the sequence of harmonic numbers begins: 1, \frac, \frac, \frac, \frac, \dot ...
. Hence the expected number of cycles of length at most ''m'' in a random permutation is about ln ''m''.


Moments of fixed points

The mixed GF g(z, u) of the set of permutations by the number of fixed points is : g(z, u) = \exp\left( -z + uz + \log \frac\right) = \frac \exp ( -z + uz ). Let the random variable ''X'' be the number of fixed points of a random permutation. Using
Stirling numbers of the second kind In mathematics, particularly in combinatorics, a Stirling number of the second kind (or Stirling partition number) is the number of ways to partition a set of ''n'' objects into ''k'' non-empty subsets and is denoted by S(n,k) or \textstyle \lef ...
, we have the following formula for the ''m''th moment of ''X'': :E(X^m) = E\left( \sum_^m \left\ (X)_k \right) = \sum_^m \left\ E((X)_k), where (X)_k is a
falling factorial In mathematics, the falling factorial (sometimes called the descending factorial, falling sequential product, or lower factorial) is defined as the polynomial :\begin (x)_n = x^\underline &= \overbrace^ \\ &= \prod_^n(x-k+1) = \prod_^(x-k) \,. \e ...
. Using g(z, u), we have :E((X)_k) = ^n\left(\frac\right)^k g(z, u) \Bigg, _ = ^n\frac \exp ( -z + uz ) \Bigg, _ = ^n\frac, which is zero when k>n, and one otherwise. Hence only terms with k<=n contribute to the sum. This yields :E(X^m) = \sum_^n \left\.


Expected number of fixed points in random permutation raised to some power ''k''

Suppose you pick a random permutation \sigma and raise it to some power k, with k a positive integer and ask about the expected number of fixed points in the result. Denote this value by E _k/math>. For every divisor d of k a cycle of length d splits into d fixed points when raised to the power k. Hence we need to mark these cycles with u^d. To illustrate this consider E _6 We get : g(z, u) = \exp\left(uz - z + u^2 \frac - \frac + u^3 \frac - \frac + u^6 \frac - \frac + \log \frac\right) which is :\frac \exp\left(uz - z + u^2 \frac - \frac + u^3 \frac - \frac + u^6 \frac - \frac\right). Once more continuing as described in the introduction, we find : \left.\frac g(z, u)\_ = \left. \frac \exp\left(uz - z + u^2 \frac - \frac + u^3 \frac - \frac + u^6 \frac - \frac\right) \_ which is :\frac. The conclusion is that E _6= 4 for n\ge 6 and there are four fixed points on average. The general procedure is :g(z, u) = \exp\left(\sum_ \left(u^d \frac - \frac\right) + \log \frac \right)= \frac \exp\left(\sum_ \left(u^d \frac - \frac\right)\right). Once more continuing as before, we find :\left.\frac g(z, u)\_ = \left. \frac \exp\left(\sum_ \left(u^d \frac - \frac\right)\right) \_ = \frac. We have shown that the value of E _k/math> is equal to \tau(k) (the
number of divisors In mathematics, and specifically in number theory, a divisor function is an arithmetic function related to the divisors of an integer. When referred to as ''the'' divisor function, it counts the ''number of divisors of an integer'' (including ...
of k) as soon as n\ge k. It starts out at 1 for n=1 and increases by one every time n hits a divisor of k up to and including k itself.


Expected number of cycles of any length of a random permutation

We construct the bivariate generating function g(z, u) using b(k), where b(k) is one for all cycles (every cycle contributes one to the total number of cycles). Note that g(z, u) has the closed form :g(z, u) = \left(\frac\right)^u and generates the unsigned
Stirling numbers of the first kind In mathematics, especially in combinatorics, Stirling numbers of the first kind arise in the study of permutations. In particular, the Stirling numbers of the first kind count permutations according to their number of cycles (counting fixed poin ...
. We have : \frac g(z, u) \Bigg, _ = \frac \sum_ b(k) \frac = \frac \sum_ \frac = \frac \log \frac. Hence the expected number of cycles is the
harmonic number In mathematics, the -th harmonic number is the sum of the reciprocals of the first natural numbers: H_n= 1+\frac+\frac+\cdots+\frac =\sum_^n \frac. Starting from , the sequence of harmonic numbers begins: 1, \frac, \frac, \frac, \frac, \dot ...
H_n, or about \log n.


Number of permutations with a cycle of length larger than ''n''/2

(Note that Section One hundred prisoners contains exactly the same problem with a very similar calculation, plus also a simpler elementary proof.) Once more, start with the exponential generating function g(z, u), this time of the class \mathcal of permutations according to size where cycles of length more than n/2 are marked with the variable u: :g(z, u) = \exp\left(u \sum_^\infty \frac + \sum_^ \frac \right). There can only be one cycle of length more than \frac, hence the answer to the question is given by :n! z^ng(z, u) = n! ^n\exp\left(\sum_^ \frac\right) \sum_^\infty \frac or :n! ^n\exp\left(\log \frac - \sum_^\infty\frac\right) \sum_^\infty \frac which is :n! ^n\frac \exp\left( - \sum_^\infty\frac\right) \sum_^\infty \frac = n! ^n\frac \sum_^\infty \frac \left( \sum_^\infty\frac\right)^ The exponent of z in the term being raised to the power m+1 is larger than \lfloor\frac \rfloor and hence no value for m>0 can possibly contribute to ^n It follows that the answer is :n! ^n\frac\sum_^\infty\frac = n! \sum_^n \frac. The sum has an alternate representation that one encounters e.g. in the OEIS . :\sum_^n \frac - \sum_^ \frac = \sum_^n \frac - 2\sum_^ \frac = \sum_^n (1-2) \frac + \sum_^n \frac finally giving :n!\sum_^n \frac \sim n! \log 2.


Expected number of transpositions of a random permutation

We can use the disjoint cycle decomposition of a permutation to factorize it as a product of transpositions by replacing a cycle of length ''k'' by ''k'' − 1 transpositions. E.g. the cycle (1 \; 2 \; 3 4) factors as (1 \; 2) \; (2 \; 3) \; (3 \; 4). The function b(k) for cycles is equal to k-1 and we obtain : g(z, u) = \left( \frac \right)^ and : \frac g(z, u) \Bigg, _ = \frac \sum_ (k-1) \frac = \frac - \frac \log \frac. Hence the expected number of transpositions T(n) is : T(n) = n - H_n where H_n is the n^
Harmonic number In mathematics, the -th harmonic number is the sum of the reciprocals of the first natural numbers: H_n= 1+\frac+\frac+\cdots+\frac =\sum_^n \frac. Starting from , the sequence of harmonic numbers begins: 1, \frac, \frac, \frac, \frac, \dot ...
. We could also have obtained this formula by noting that the number of transpositions is obtained by adding the lengths of all cycles (which gives ''n'') and subtracting one for every cycle (which gives \log n by the previous section). Note that g(z, u) again generates the unsigned
Stirling numbers of the first kind In mathematics, especially in combinatorics, Stirling numbers of the first kind arise in the study of permutations. In particular, the Stirling numbers of the first kind count permutations according to their number of cycles (counting fixed poin ...
, but in reverse order. More precisely, we have : (-1)^m n! \; ^n ^mg(z, u) = \left begin n \\ n-m \end\right To see this, note that the above is equivalent to : (-1)^ n! \; ^n ^mg(z, u), _ , _ = \left begin n \\ m \end\right and that : ^mg(z, u), _ , _ = ^m\left( \frac \right)^u = \frac \left( \log \frac \right)^m, which we saw to be the EGF of the unsigned Stirling numbers of the first kind in the section on permutations consisting of precisely ''m'' cycles.


Expected cycle size of a random element

We select a random element ''q'' of a random permutation \sigma and ask about the expected size of the cycle that contains ''q''. Here the function b(k) is equal to k^2, because a cycle of length ''k'' contributes ''k'' elements that are on cycles of length ''k''. Note that unlike the previous computations, we need to average out this parameter after we extract it from the generating function (divide by ''n''). We have : \frac g(z, u) \Bigg, _ = \frac \sum_ k^2 \frac = \frac \frac = \frac. Hence the expected length of the cycle that contains ''q'' is : \frac ^n\frac = \frac \frac n (n+1) = \frac (n+1).


Probability that a random element lies on a cycle of size ''m''

This average parameter represents the probability that if we again select a random element of /math> of a random permutation, the element lies on a cycle of size ''m''. The function b(k) is equal to m for m=k and zero otherwise, because only cycles of length ''m'' contribute, namely ''m'' elements that lie on a cycle of length ''m''. We have : \frac g(z, u) \Bigg, _ = \frac \sum_ b(k) \frac = \frac \; m \; \frac = \frac. It follows that the probability that a random element lies on a cycle of length ''m'' is : \frac ^n\frac = \begin \frac, & \mboxn\ge m \\ 0, & \mbox \end


Probability that a random subset of 'n''lies on the same cycle

Select a random subset ''Q'' of 'n''containing ''m'' elements and a random permutation, and ask about the probability that all elements of ''Q'' lie on the same cycle. This is another average parameter. The function ''b''(''k'') is equal to \begin\end, because a cycle of length ''k'' contributes \begin\end subsets of size ''m'', where \begin = 0\end for . This yields : \frac g(z, u) \Bigg, _ = \frac \sum_ \frac = \frac \frac \frac = \frac \frac. Averaging out we obtain that the probability of the elements of ''Q'' being on the same cycle is : ^ ^n\frac \frac = ^ \frac ^\frac or : \frac ^ = \frac. In particular, the probability that two elements are on the same cycle is 1/2.


Number of permutations containing an even number of even cycles

We may use the
Flajolet–Sedgewick fundamental theorem In combinatorics, the symbolic method is a technique for counting combinatorial objects. It uses the internal structure of the objects to derive formulas for their generating functions. The method is mostly associated with Philippe Flajolet and ...
directly and compute more advanced permutation statistics. (Check that page for an explanation of how the operators we will use are computed.) For example, the set of permutations containing an even number of even cycles is given by :\operatorname(\operatorname_(\mathcal)) \operatorname_(\operatorname_(\mathcal)). Translating to
exponential generating function In mathematics, a generating function is a way of encoding an infinite sequence of numbers () by treating them as the coefficients of a formal power series. This series is called the generating function of the sequence. Unlike an ordinary ser ...
s (EGFs), we obtain : \exp \left( \frac \log \frac \right) \cosh \left( \frac \log \frac \right) or : \frac \exp \left( \frac \left( \log \frac + \log \frac \right) \right) + \frac \exp \left( \frac \left( \log \frac - \log \frac \right) \right). This simplifies to : \frac \exp \left( \frac \log \frac \right) + \frac \exp \left( \frac \log (1+z)^2 \right) or : \frac \frac + \frac (1+z) = 1 + z + \frac \frac. This says that there is one permutation of size zero containing an even number of even cycles (the empty permutation, which contains zero cycles of even length), one such permutation of size one (the fixed point, which also contains zero cycles of even length), and that for n\ge 2, there are n!/2 such permutations.


Permutations that are squares

Consider what happens when we square a permutation. Fixed points are mapped to fixed points. Odd cycles are mapped to odd cycles in a one-to-one correspondence, e.g. (1 \; 8 \; 9 \; 11 \; 13) turns into (1 \; 9 \; 13 \; 8 \; 11). Even cycles split in two and produce a pair of cycles of half the size of the original cycle, e.g. (5 \; 13 \; 6 \; 9) turns into (5 \; 6) \; (9 \; 13). Hence permutations that are squares may contain any number of odd cycles, and an even number of cycles of size two, an even number of cycles of size four etc., and are given by : \operatorname(\operatorname_\operatorname(\mathcal)) \operatorname_\operatorname(\operatorname_(\mathcal)) \operatorname_\operatorname(\operatorname_(\mathcal)) \operatorname_\operatorname(\operatorname_(\mathcal)) \cdots which yields the EGF : \exp \left( \frac \log \frac \right) \prod_ \cosh \frac = \sqrt \prod_ \cosh \frac.


Odd cycle invariants

The types of permutations presented in the preceding two sections, i.e. permutations containing an even number of even cycles and permutations that are squares, are examples of so-called odd cycle invariants, studied by Sung and Zhang (see
external links An internal link is a type of hyperlink on a web page to another page or resource, such as an image or document, on the same website or domain. Hyperlinks are considered either "external" or "internal" depending on their target or destination ...
). The term odd cycle invariant simply means that membership in the respective combinatorial class is independent of the size and number of odd cycles occurring in the permutation. In fact we can prove that all odd cycle invariants obey a simple recurrence, which we will derive. First, here are some more examples of odd cycle invariants.


Permutations where the sum of the lengths of the even cycles is six

This class has the specification : \operatorname(\operatorname_\operatorname(\mathcal)) \left( \operatorname_(\operatorname_(\mathcal)) + \operatorname_(\mathcal)\operatorname_(\mathcal) + \operatorname_(\mathcal) \right) and the generating function : \sqrt \left( \frac \left( \frac \right)^3 + \frac \frac + \frac \right) = \frac z^6 \sqrt. The first few values are :0, 0, 0, 0, 0, 225, 1575, 6300, 56700, 425250, 4677750, 46777500, 608107500, \ldots


Permutations where all even cycles have the same length

This class has the specification : \operatorname(\operatorname_\operatorname(\mathcal)) \left( \operatorname_(\operatorname_(\mathcal)) + \operatorname_(\operatorname_(\mathcal)) + \operatorname_(\operatorname_(\mathcal)) + \cdots \right) and the generating function : \sqrt \left( \exp\left(\frac\right)-1 \, + \, \exp\left(\frac\right)-1 \, + \, \exp\left(\frac\right)-1 \, + \, \cdots \right). There is a semantic nuance here. We could consider permutations containing no even cycles as belonging to this class, since zero is even. The first few values are :0, 1, 3, 15, 75, 405, 2835, 22155, 199395, 1828575, \ldots


Permutations where the maximum length of an even cycle is four

This class has the specification : \operatorname(\operatorname_\operatorname(\mathcal)) \operatorname(\operatorname_(\mathcal) + \operatorname_(\mathcal)) and the generating function : \sqrt \exp \left( \frac + \frac \right). The first few values are :1, 2, 6, 24, 120, 600, 4200, 28560, 257040, 2207520, 24282720, 258128640, \ldots


The recurrence

Observe carefully how the specifications of the even cycle component are constructed. It is best to think of them in terms of parse trees. These trees have three levels. The nodes at the lowest level represent sums of products of even-length cycles of the singleton \mathcal. The nodes at the middle level represent restrictions of the set operator. Finally the node at the top level sums products of contributions from the middle level. Note that restrictions of the set operator, when applied to a generating function that is even, will preserve this feature, i.e. produce another even generating function. But all the inputs to the set operators are even since they arise from even-length cycles. The result is that all generating functions involved have the form :g(z) = h(z) \sqrt, where h(z) is an even function. This means that :\frac \; g(z) = h(z) \; \frac is even, too, and hence :\frac \; g(z) = \frac \; g(-z) \quad \mbox \quad (1-z) \; g(z) = (1+z) \; g(-z). Letting g_n = ^ng(z) and extracting coefficients, we find that : \frac - \frac = - \frac + \frac \quad \mbox \quad 2 \frac = 2 \frac which yields the recurrence : g_ = (2m+1) g_\,.


A problem from the 2005 Putnam competition

A link to the
Putnam competition The William Lowell Putnam Mathematical Competition, often abbreviated to Putnam Competition, is an annual mathematics competition for undergraduate college students enrolled at institutions of higher learning in the United States and Canada (regar ...
website appears in the section
External links An internal link is a type of hyperlink on a web page to another page or resource, such as an image or document, on the same website or domain. Hyperlinks are considered either "external" or "internal" depending on their target or destination ...
. The problem asks for a proof that :\sum_ \frac = (-1)^ \frac, where the sum is over all n! permutations of /math>, \sigma(\pi) is the sign of \pi, i.e. \sigma(\pi)= 1 if \pi is even and \sigma(\pi)=-1 if \pi is odd, and \nu(\pi) is the number of fixed points of \pi. Now the sign of \pi is given by : \sigma(\pi) = \prod_ (-1)^, where the product is over all cycles ''c'' of \pi, as explained e.g. on the page on
even and odd permutations In mathematics, when ''X'' is a finite set with at least two elements, the permutations of ''X'' (i.e. the bijective functions from ''X'' to ''X'') fall into two classes of equal size: the even permutations and the odd permutations. If any total or ...
. Hence we consider the combinatorial class : \operatorname( - \mathcal + \mathcal \mathcal + \operatorname_(\mathcal) + \mathcal\operatorname_(\mathcal) + \mathcal^2\operatorname_(\mathcal) + \mathcal^3\operatorname_(\mathcal) + \cdots) where \mathcal marks one minus the length of a contributing cycle, and \mathcal marks fixed points. Translating to generating functions, we obtain :g(z, u, v) = \exp\left( -z + vz + \sum_ u^ \frac \right) or : \exp\left( -z + vz + \frac \log\frac \right) = \exp(-z + vz) \left(\frac \right)^. Now we have :n! ^ng(z, -1, v) = n! ^n\exp(-z + vz) (1 + z) = \sum_ \sigma(\pi) v^ and hence the desired quantity is given by :n! ^n\int_0^1 g(z, -1, v) dv = \sum_ \frac. Doing the computation, we obtain : \int_0^1 g(z, -1, v) dv = \exp(-z)(1+z) \left(\frac\exp(z) - \frac\right) or : \left(\frac + 1\right) \left(1 - \exp(-z)\right) = \frac + 1 - \exp(-z) - \frac \exp(-z). Extracting coefficients, we find that the coefficient of 1/z is zero. The constant is one, which does not agree with the formula (should be zero). For n positive, however, we obtain : n! ^n\left( - \exp(-z) - \frac \exp(-z) \right) = n! \left( - (-1)^n \frac - (-1)^ \frac \right) or : (-1)^ \left( 1 - \frac \right) = (-1)^ \frac, which is the desired result. As an interesting aside, we observe that g(z, u, v) may be used to evaluate the following
determinant In mathematics, the determinant is a scalar value that is a function of the entries of a square matrix. It characterizes some properties of the matrix and the linear map represented by the matrix. In particular, the determinant is nonzero if and ...
of an n\times n matrix: :d(n) = \det(A_n) = \begin a && b && b && \cdots && b \\ b && a && b && \cdots && b \\ b && b && a && \cdots && b \\ \vdots && \vdots && \vdots && \ddots && \vdots \\ b && b && b && \cdots && a \end. where a, b \ne 0. Recall the formula for the determinant: :\det(A) = \sum_ \sigma(\pi) \prod_^n A_. Now the value of the product on the right for a permutation \pi is a^f b^, where ''f'' is the number of fixed points of \pi. Hence : d(n) = b^n n! ^ng\left(z, -1, \frac\right)= b^n n! ^n\exp \left(\frac z\right) (1+z) which yields : b^n \left(\frac\right)^n + b^n n \left(\frac\right)^ = (a-b)^n + n b (a-b)^ and finally :d(n) = (a + (n-1)b) (a-b)^\,.


The difference between the number of cycles in even and odd permutations

Here we seek to show that this difference is given by : (-1)^n (n-2)! Recall that the sign \sigma(\pi) of a permutation \pi is given by :\sigma(\pi) = \prod_ (-1)^ where the product ranges over the cycles ''c'' from the disjoint cycle composition of \pi. It follows that the combinatorial species \mathcal that reflects the signs and the cycle count of the set of permutations is given by :\mathcal = \operatorname(\mathcal\operatorname_1(\mathcal) +\mathcal\mathcal\operatorname_(\mathcal)) +\mathcal^2\mathcal\operatorname_(\mathcal) +\mathcal^3\mathcal\operatorname_(\mathcal) +\mathcal^4\mathcal\operatorname_(\mathcal) +\cdots) where we have used \mathcal to mark signs and \mathcal for the cycle count. Translating to generating functions we have :Q(z, u, v) = \exp\left(v\frac + vu\frac + vu^2\frac + vu^3\frac + vu^4\frac +\cdots\right). This simplifies to :Q(z,u,v) = \exp\left(\frac \left( \frac + \frac + \frac + \frac + \frac + \cdots \right)\right) which is :\exp\left(\frac \log \frac\right) = \left(\frac\right)^. Now the two generating functions Q_1(z, v) and Q_2(z, v) of even and odd permutations by cycle count are given by :Q_1(z,v) = \frac Q(z,+1,v) + \frac Q(z,-1,v) = \frac\left(\frac\right)^v +\frac\left(\frac\right)^ and :Q_2(z,v) = \frac Q(z,+1,v) - \frac Q(z,-1,v) = \frac\left(\frac\right)^v -\frac\left(\frac\right)^. We require the quantity :G(z, v) = \left.\frac (Q_1(z,v)-Q_2(z,v))\_ which is : \left.\frac \left(\frac\right)^\_ = - \left.\log \frac \left(\frac\right)^\_ = -(1+z)\log \frac. Finally, extracting coefficients from this generating function, we obtain :- n! ^n(1+z)\log \frac = - n! \left(\frac + \frac\right) which is : - n! (-1)^ \left(-\frac + \frac\right) = n! (-1)^n \frac which is in turn : n! (-1)^n \frac = (-1)^n (n-2)! This concludes the proof.


See also

*
Golomb–Dickman constant In mathematics, the Golomb–Dickman constant arises in the theory of random permutations and in number theory. Its value is :\lambda = 0.62432 99885 43550 87099 29363 83100 83724\dots It is not known whether this constant is rational or irration ...


References


External links

* * Marko Riedel et al.,
The difference of number of cycles of even and odd permutations
' * Marko Riedel et al.,
Keys inside closed boxes, a question on probability
'


100 prisoners

* Various authors,
Permutations with a cycle > n/2
' * Various authors,
A property of derangements
' * Various authors,
Expected number of fixed points
' * Peter Winkler,
Seven puzzles you think you must not have heard correctly
' * Various authors,
Les-Mathematiques.net
'.
Cent prisonniers
' {{in lang, fr Combinatorics