Random permutation statistics

Random permutation statistics

The statistics of random permutations, such as the cycle structure of a random permutation are of fundamental importance in the analysis of algorithms, especially of sorting algorithms, which operate on random permutations. Suppose, for example, that we are using quickselect (a cousin of quicksort) 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 permutations contains an introduction to random permutations.

Contents

The fundamental relation

Permutations are sets of labelled cycles. Using the labelled case of the fundamental theorem of combinatorial enumeration and writing \scriptstyle\mathcal{P} for the set of permutations and \scriptstyle\mathcal{Z} for the singleton set, we have

 \mathfrak{P}(\mathfrak{C}(\mathcal{Z})) = \mathcal{P}.

Translating into exponential generating functions (EGFs), we have

 \exp \log \frac{1}{1-z} = \frac{1}{1-z}

where we have used the fact that the EGF of the set of permutations (there are n! permutations of n elements) is

 \sum_{n\ge 0} \frac{n!}{n!} z^n = \frac{1}{1-z}.

This one equation will allow us to derive a surprising number of permutation statistics. Firstly, by dropping terms from \scriptstyle\mathfrak{P}, i.e. exp, we may constrain the number of cycles that a permutation contains, e.g. by restricting the EGF to \scriptstyle\mathfrak{P}_2 we obtain permutations containing two cycles. Secondly, note that the EGF of labelled cycles, i.e. of \scriptstyle\mathfrak{C}(\mathcal{Z}), is

 \log \frac{1}{1-z} = \sum_{k\ge 1} \frac{z^k}{k}

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.

Now instead of dropping, let's put different weights on different size cycles. If \scriptstyle b(k): \mathbb{N} \rightarrow \mathbb{R} is a weight function that depends only on the size k of the cycle and for brevity we write

b(\sigma) = \sum_{c\in\sigma} b(c)

the value of b for a permutation σ to be the sum of its values on the cycles, then we may mark cycles of length k with ub(k) and obtain a bivariate generating function g(zu) that describes the parameter, i.e.

 g(z, u) = 
1 + \sum_{n\ge 1} \left( \sum_{\sigma\in S_n} u^{b(\sigma)} \right) \frac{z^n}{n!} =
\exp \sum_{k\ge 1} u^{b(k)} \frac{z^k}{k}

This is a mixed generating function which is exponential in the permutation size and ordinary in the secondary parameter u. Differentiating and evaluating at u = 1, we have

 \frac{\partial}{\partial u} g(z, u) \Bigg|_{u=1} = 
\frac{1}{1-z} \sum_{k\ge 1} b(k) \frac{z^k}{k} =
\sum_{n\ge 1} \left( \sum_{\sigma\in S_n} b(\sigma) \right) \frac{z^n}{n!}

i.e. the EGF of the sum of b over all permutations, or alternatively, the OGF, or more precisely, PGF (probability generating function) of the expectation of b.

This article uses the coefficient extraction operator [zn], documented on the page for formal power series.

Number of permutations that are involutions

An involution 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 EGF g(z) of these permutations is

g(z) = \exp\left(z + \frac{1}{2} z^2\right).

This gives the explicit formula for the total number I(n) of involutions among the permutations σ ∈ Sn:

 I(n) = n! [z^n] g(z) = n! \sum_{a+2b=n} \frac{1}{a! \; 2^b \; b!}
= n! \sum_{b=0}^{\lfloor n/2 \rfloor} \frac{1}{(n-2b)! \; 2^b \; b!}.

Dividing by n! yields the probability that a random permutation is an involution.

Number of permutations that are mth roots of unity

This generalizes the concept of an involution. An mth 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_{d|m} \frac{z^d}{d}\right).

When m = p, where p is prime, this simplifies to

 n! [z^n] g(z) = n! \sum_{a+pb=n} \frac{1}{a! \; p^b \; b!}
= n! \sum_{b=0}^{\lfloor n/p \rfloor} \frac{1}{(n-pb)! \; p^b \; b!}.

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, and hence the EGF (subtract out fixed points by removing z) g(x) is

\exp \left( -z + \sum_{k\ge 1} \frac{z^k}{k} \right)
= \frac{e^{-z}}{1-z}.

Now multiplication by 1 / (1 − z) just sums coefficients, so that we have the following formula for D(n), the total number of derangements:

 D(n) = n! \sum_{k=0}^n \frac{(-1)^k}{k!} \; \approx \; \frac{n!}{e}.

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 Ap where \begin{matrix}1\le p\le n\end{matrix} to denote the set of permutations that fix p, we have

 \left| \bigcup_p A_p \right| =
     \sum_p \left| A_p \right| \;
- \; \sum_{p<q} \left| A_p \cap A_q \right| \;
+ \; \sum_{p<q<r} \left| A_p \cap A_q \cap A_r \right| \;
- \; \cdots \;
\pm \; \left| A_p \cap \; \cdots \; \cap A_s \right|.

This formula counts the number of permutations that have at least one fixed point. The cardinalities are as follows:


\left| A_p \right| = (n-1)!\; , \; \;
\left| A_p \cap A_q \right| = (n-2)!\; , \; \;
\left| A_p \cap A_q \cap A_r \right| = (n-3)!\; , \; \ldots

Hence the number of permutations with no fixed point is

n!
\; \; - \; \; {n \choose 1} (n-1)!
\; \; + \; \; {n \choose 2} (n-2)!
\; \; - \; \; {n \choose 3} (n-3)!
\; \; + \; \; \cdots
\; \; \pm \; \; {n \choose n} (n-n)!

or


n!
\left(
1 - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \cdots \pm \frac{1}{n!}
\right)
=
n! \sum_{k=0}^n \frac{(-1)^k}{k!}

and we have the claim.

There is a generalization of these numbers, which is known as rencontres numbers, i.e. the number D(n,m) of permutations of [n] 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_{k\ge 1} \frac{z^k}{k} \right)
= \frac{e^{-z}}{1-z} e^{uz}.

It follows that


[u^m] g(z, u) = \frac{e^{-z}}{1-z} \frac{z^m}{m!}

and hence

 D(n, m)
= n! [z^n] [u^m] g(z, u) = \frac{n!}{m!} [z^{n-m}] \frac{e^{-z}}{1-z}
= \frac{n!}{m!} \sum_{k=0}^{n-m} \frac{(-1)^k}{k!}.

This immediately implies that

 D(n, m) = {n \choose m} D(n-m, 0) \; \; \mbox{ and } \; \;
\frac{D(n, m)}{n!} \approx \frac{e^{-1}}{m!}

for n large, m fixed.

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{{99 \choose 49}}{{100 \choose 50}} \right)^{100} =
\frac{1}{2^{100}},

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{z^2}{2} + \frac{z^3}{3} + \cdots + 
u \frac{z^{n+1}}{n+1} + u \frac{z^{n+2}}{n+2} + \cdots \right)

or


\frac{1}{1-z}
\exp \left( (u-1) \left( \frac{z^{n+1}}{n+1} + \frac{z^{n+2}}{n+2} + \cdots \right) \right),

so that the desired probability is

 [z^{2n}][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

 [z^{2n}][u] g(z, u) =
[z^{2n}][u] \frac{1}{1-z}
\left( 1 + (u-1) \left( \frac{z^{n+1}}{n+1} + \frac{z^{n+2}}{n+2} + \cdots \right) \right),

which yields

[z^{2n}][u] g(z, u) =
[z^{2n}] \frac{1}{1-z} \left( \frac{z^{n+1}}{n+1} + \frac{z^{n+2}}{n+2} + \cdots \right) =
\sum_{k=n+1}^{2n} \frac{1}{k} = H_{2n} - H_n.

Finally, using an integral estimate such as Euler–MacLaurin summation, or the asymptotic expansion of the nth harmonic number, we obtain

 H_{2n} - H_n \sim
\log 2 - \frac{1}{4n} + \frac{1}{16n^2} - \frac{1}{128n^4} + \frac{1}{256n^6} - \frac{17}{4096n^8}
+ \cdots,

so that

 [z^{2n}][u] g(z, u) < \log 2
\quad \mbox{and} \quad 1 - [z^{2n}][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 a λn, where λ is the Golomb–Dickman constant, 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

pk = Pr[there is a cycle of length k],

then

\Pr[\mbox{there is a cycle of length}> n] = \sum_{k=n+1}^{2n} p_k.

For k > n, the number of permutations that contain a cycle of length exactly k is

{{2n}\choose k} \cdot \frac{k!}{k} \cdot (2n-k)!.

Explanation: {{2n}\choose k} is the number of ways of choosing the k elements that consist the cycle;  \frac{k!}{k} is the number of ways of arranging k items in a cycle; and (2nk)! is the number of ways to permute the remaining elements. Thus,

p_k = \frac{{{2n}\choose k} \cdot \frac{k!}{k} \cdot (2n-k)!}{(2n)!} = \frac1k.

We conclude that

\Pr[\mbox{there is a cycle of length}> n] = \sum_{k=n+1}^{2n} \frac1k = H_{2n}-H_n.

Number of permutations containing m cycles

Applying the fundamental theorem of combinatorial enumeration, i.e. the labelled enumeration theorem with G = Sm, to the set

\mathfrak{P}_m(\mathfrak{C}(\mathcal{Z}))

we obtain the generating function

 g_m(z) =
\frac{1}{|S_m|} \left( \log \frac{1}{1-z} \right)^m =
\frac{1}{m!} \left( \log \frac{1}{1-z} \right)^m.

The term

 (-1)^{n+m} n! \; [z^n] g_m(z) =
\left[\begin{matrix} n \\ m \end{matrix}\right]

yields the Stirling numbers of the first kind, i.e. gm(z) is the EGF of the unsigned Stirling numbers of the first kind.

We can compute the OGF of these numbers for n fixed, i.e.

 s_n(w) =
\sum_{m=0}^n \left[\begin{matrix} n \\ m \end{matrix}\right] w^m.

Start with

 g_m(z) = 
\sum_{n\ge m} \frac{(-1)^{n+m}}{n!} 
\left[\begin{matrix} n \\ m \end{matrix}\right] z^n

which yields

 (-1)^m g_m(z) w^m = 
\sum_{n\ge m} \frac{(-1)^n}{n!} 
\left[\begin{matrix} n \\ m \end{matrix}\right] w^m z^n.

Summing this, we obtain

 \sum_{m\ge 0} (-1)^m g_m(z) w^m =
\sum_{m\ge 0} \sum_{n\ge m} \frac{(-1)^n}{n!} 
\left[\begin{matrix} n \\ m \end{matrix}\right] w^m z^n =
\sum_{n\ge 0}\frac{(-1)^n}{n!} z^n 
\sum_{m=0}^n \left[\begin{matrix} n \\ m \end{matrix}\right] w^m.

Using the formula for gm(z) on the left, the definition of sn(w) on the right, and the binomial theorem, we obtain

 (1-z)^w = \sum_{n\ge 0} {w \choose n} (-1)^n z^n =
\sum_{n\ge 0}\frac{(-1)^n}{n!} s_n(w) z^n.

Comparing the coefficients of zn, and using the definition of the binomial coefficient, we finally have

 s_n(w) = w \; (w-1) \; (w-2) \; \cdots \; (w-(n-1)) = (w)_n,

a falling factorial.

Expected number of cycles of a given size m

In this problem we use a bivariate generating function g(zu) 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{\partial}{\partial u} g(z, u) \Bigg|_{u=1} = 
\frac{1}{1-z} \sum_{k\ge 1} b(k) \frac{z^k}{k} =
\frac{1}{1-z} \frac{z^m}{m}

or


\frac{1}{m} z^m \; + \;
\frac{1}{m} z^{m+1} \; + \;
\frac{1}{m} z^{m+2} \; + \; \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{1}{1-z} \sum_{k=1}^m \frac{z^k}{k}
\mbox{ and }
[z^n] \frac{1}{1-z} \sum_{k=1}^m \frac{z^k}{k} = H_m
\mbox{ for }
n \ge m

where Hm is the mth harmonic number. 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{1}{1-z}\right) = 
\frac{1}{1-z} \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, we have the following formula for the mth moment of X:

E(X^m) = 
E\left( \sum_{k=0}^m \left\{ \begin{matrix} m \\ k \end{matrix} \right\} (X)_k \right) =
\sum_{k=0}^m \left\{ \begin{matrix} m \\ k \end{matrix} \right\} E((X)_k),

where (X)k is a falling factorial. Using g(z,u), we have

E((X)_k) =
[z^n] \left(\frac{d}{du}\right)^k g(z, u) \Bigg|_{u=1} =
[z^n] \frac{z^k}{1-z} \exp ( -z + uz ) \Bigg|_{u=1} = 
[z^n] \frac{z^k}{1-z},

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_{k=0}^n \left\{ \begin{matrix} m \\ k \end{matrix} \right\}.

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{1}{1-z}\right)^u

and generates the unsigned Stirling numbers of the first kind.

We have

 \frac{\partial}{\partial u} g(z, u) \Bigg|_{u=1} = 
\frac{1}{1-z} \sum_{k\ge 1} b(k) \frac{z^k}{k} =
\frac{1}{1-z} \sum_{k\ge 1} \frac{z^k}{k} =
\frac{1}{1-z} \log \frac{1}{1-z}.

Hence the expected number of cycles is Hn, or about log n.

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{1}{1-uz} \right)^{1/u}

and

 \frac{\partial}{\partial u} g(z, u) \Bigg|_{u=1} = 
\frac{1}{1-z} \sum_{k\ge 1} (k-1) \frac{z^k}{k} =
\frac{z}{(1-z)^2} - \frac{1}{1-z} \log \frac{1}{1-z}.

Hence the expected number of transpositions T(n) is

 T(n) = n - \log n.\,

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, but in reverse order. More precisely, we have

 (-1)^m n! \; [z^n] [u^m] g(z, u) = 
\left[\begin{matrix} n \\ n-m \end{matrix}\right]

To see this, note that the above is equivalent to

 (-1)^{n+m} n! \; [z^n] [u^m] g(z, u)|_{u=1/u} |_{z=uz} = 
\left[\begin{matrix} n \\ m \end{matrix}\right]

and that


[u^m] g(z, u)|_{u=1/u} |_{z=uz} =
[u^m] \left( \frac{1}{1-z} \right)^u = 
\frac{1}{m!} \left( \log \frac{1}{1-z} \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 σ and ask about the expected size of the cycle that contains q. Here the function b(k) is equal to k2, 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{\partial}{\partial u} g(z, u) \Bigg|_{u=1} = 
\frac{1}{1-z} \sum_{k\ge 1} k^2 \frac{z^k}{k} =
\frac{1}{1-z} \frac{z}{(1-z)^2} = \frac{z}{(1-z)^3}.

Hence the expected length of the cycle that contains q is

 \frac{1}{n} [z^n] \frac{z}{(1-z)^3} = 
\frac{1}{n} \frac{1}{2} n (n+1) = \frac{1}{2} (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 [n] 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{\partial}{\partial u} g(z, u) \Bigg|_{u=1} = 
\frac{1}{1-z} \sum_{k\ge 1} b(k) \frac{z^k}{k} =
\frac{1}{1-z} \; m \; \frac{z^m}{m} = \frac{z^m}{1-z}.

It follows that the probability that a random element lies on a cycle of length m is

 \frac{1}{n} [z^n] \frac{z^m}{1-z} =  
\begin{cases} 
\frac{1}{n}, & \mbox{if }n\ge m \\ 
0, & \mbox{otherwise.}
\end{cases}

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{matrix}{k \choose m}\end{matrix}, because a cycle of length k contributes \begin{matrix}{k \choose m}\end{matrix} subsets of size m, where \begin{matrix}{k \choose m} = 0\end{matrix} for k < m. This yields

 \frac{\partial}{\partial u} g(z, u) \Bigg|_{u=1} = 
\frac{1}{1-z} \sum_{k\ge m} {k \choose m} \frac{z^k}{k} =
\frac{1}{1-z} \frac{1}{m} \frac{z^m}{(1-z)^m} =
\frac{1}{m} \frac{z^m}{(1-z)^{m+1}}.

Averaging out we obtain that the probability of the elements of Q being on the same cycle is

 {n \choose m}^{-1} [z^n] \frac{1}{m} \frac{z^m}{(1-z)^{m+1}} =
{n \choose m}^{-1} \frac{1}{m} [z^{n-m}] \frac{1}{(1-z)^{m+1}}

or


\frac{1}{m} {n \choose m}^{-1} {(n-m) \; + \; m \choose m} = \frac{1}{m}.

In particular, the probability that two elements p < q are on the same cycle is 1/2.

Number of permutations containing an even number of even cycles

We may use the Fundamental Theorem of Combinatorial Enumeration 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

\mathfrak{P}(\mathfrak{C}_\operatorname{odd}(\mathcal{Z}))
\mathfrak{P}_\operatorname{even}(\mathfrak{C}_\operatorname{even}(\mathcal{Z})).

Translating to exponential generating functions (EGFs), we obtain


\exp \left( \frac{1}{2} \log \frac{1+z}{1-z} \right)
\cosh \left( \frac{1}{2} \log \frac{1}{1-z^2} \right)

or


\frac{1}{2} 
\exp \left( \frac{1}{2} \left( \log \frac{1+z}{1-z} + \log \frac{1}{1-z^2} \right) \right)
+
\frac{1}{2}
\exp \left( \frac{1}{2} \left( \log \frac{1+z}{1-z} - \log \frac{1}{1-z^2} \right) \right).

This simplifies to


\frac{1}{2}
\exp \left( \frac{1}{2} \log \frac{1}{(1-z)^2} \right)
+
\frac{1}{2}
\exp \left( \frac{1}{2} \log (1+z)^2 \right)

or


\frac{1}{2} \frac{1}{1-z} + \frac{1}{2} (1+z)
=
1 + z + \frac{1}{2} \frac{z^2}{1-z}.

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


\mathfrak{P}(\mathfrak{C}_\operatorname{odd}(\mathcal{Z}))
\mathfrak{P}_\operatorname{even}(\mathfrak{C}_2(\mathcal{Z}))
\mathfrak{P}_\operatorname{even}(\mathfrak{C}_4(\mathcal{Z}))
\mathfrak{P}_\operatorname{even}(\mathfrak{C}_6(\mathcal{Z}))
\cdots

which yields the EGF


\exp \left( \frac{1}{2} \log \frac{1+z}{1-z} \right)
\prod_{m\ge 1} \cosh \frac{z^{2m}}{2m} =
\sqrt{\frac{1+z}{1-z}}
\prod_{m\ge 1} \cosh \frac{z^{2m}}{2m}.

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). 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


\mathfrak{P}(\mathfrak{C}_\operatorname{odd}(\mathcal{Z}))
\left(
\mathfrak{P}_3(\mathfrak{C}_2(\mathcal{Z})) +
\mathfrak{C}_2(\mathcal{Z})\mathfrak{C}_4(\mathcal{Z}) +
\mathfrak{C}_6(\mathcal{Z})
\right)

and the generating function


\sqrt{\frac{1+z}{1-z}}
\left(
\frac{1}{6} \left( \frac{z^2}{2} \right)^3 +
\frac{z^2}{2} \frac{z^4}{4} +
\frac{z^6}{6}
\right) =
\frac{5}{16} z^6
\sqrt{\frac{1+z}{1-z}}.

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


\mathfrak{P}(\mathfrak{C}_\operatorname{odd}(\mathcal{Z}))
\left(
\mathfrak{P}_{\ge 1}(\mathfrak{C}_2(\mathcal{Z})) +
\mathfrak{P}_{\ge 1}(\mathfrak{C}_4(\mathcal{Z})) +
\mathfrak{P}_{\ge 1}(\mathfrak{C}_6(\mathcal{Z})) + \cdots
\right)

and the generating function


\sqrt{\frac{1+z}{1-z}}
\left(
\exp\left(\frac{z^2}{2}\right)-1 \, + \,
\exp\left(\frac{z^4}{4}\right)-1 \, + \,
\exp\left(\frac{z^6}{6}\right)-1 \, + \, \cdots
\right).

There is a sematic 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


\mathfrak{P}(\mathfrak{C}_\operatorname{odd}(\mathcal{Z}))
\mathfrak{P}(\mathfrak{C}_2(\mathcal{Z}) + \mathfrak{C}_4(\mathcal{Z}))

and the generating function


\sqrt{\frac{1+z}{1-z}}
\exp \left( \frac{z^2}{2} + \frac{z^4}{4} \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{Z}. 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{\frac{1+z}{1-z}},

where h(z) is an even function. This means that

\frac{1}{1+z} \; g(z) = h(z) \; \frac{1}{\sqrt{1-z^2}}

is even, too, and hence

\frac{1}{1+z} \; g(z) = \frac{1}{1-z} \; g(-z) \quad \mbox{ or } \quad
(1-z) \; g(z) = (1+z) \; g(-z).

Letting g_n = [z^n] g(z)\, and extracting coefficients, we find that

 \frac{g_{2m+1}}{(2m+1)!} - \frac{g_{2m}}{(2m)!} =
- \frac{g_{2m+1}}{(2m+1)!} + \frac{g_{2m}}{(2m)!} \quad \mbox{ or } \quad
2 \frac{g_{2m+1}}{(2m+1)!} = 2 \frac{g_{2m}}{(2m)!}

which yields the recurrence

 g_{2m+1} = (2m+1) g_{2m}\,.

A problem from the 2005 Putnam competition

A link to the Putnam competition website appears in the section External links. The problem asks for a proof that

\sum_{\pi\in S_n} \frac{\sigma(\pi)}{\nu(\pi)+1} = 
(-1)^{n+1} \frac{n}{n+1},

where the sum is over all n! permutations of [n], σ(π) is the sign of π, i.e. σ(π) = 1 if π is even and σ(π) = − 1 if π is odd, and ν(π) is the number of fixed points of π.

Now the sign of π is given by

 \sigma(\pi) = \prod_{c\in\pi} (-1)^{|c|-1},

where the product is over all cycles c of π, as explained e.g. on the page on even and odd permutations.

Hence we consider the combinatorial class


\mathfrak{P}(
- \mathcal{Z} + \mathcal{V} \mathcal{Z} +
\mathfrak{C}_1(\mathcal{Z}) + 
\mathcal{U}\mathfrak{C}_2(\mathcal{Z}) + 
\mathcal{U}^2\mathfrak{C}_3(\mathcal{Z}) + 
\mathcal{U}^3\mathfrak{C}_4(\mathcal{Z}) + \cdots)

where \mathcal{U} marks one minus the length of a contributing cycle, and \mathcal{V} marks fixed points. Translating to generating functions, we obtain

g(z, u, v) =
\exp\left( -z + vz + \sum_{k\ge 1} u^{k-1} \frac{z^k}{k} \right)

or


\exp\left( -z + vz + \frac{1}{u} \log\frac{1}{1-uz} \right) =
\exp(-z + vz) \left(\frac{1}{1-uz} \right)^{1/u}.

Now we have

n! [z^n] g(z, -1, v) = 
n! [z^n] \exp(-z + vz) (1 + z) = 
\sum_{\pi\in S_n} \sigma(\pi) v^{\nu(\pi)}

and hence the desired quantity is given by

n! [z^n] \int_0^1 g(z, -1, v) dv = 
\sum_{\pi\in S_n} \frac{\sigma(\pi)}{\nu(\pi)+1}.

Doing the computation, we obtain

 \int_0^1 g(z, -1, v) dv = 
\exp(-z)(1+z) \left(\frac{1}{z}\exp(z) - \frac{1}{z}\right)

or


\left(\frac{1}{z} + 1\right) \left(1 - \exp(-z)\right) =
\frac{1}{z} + 1 - \exp(-z) - \frac{1}{z} \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! [z^n] \left( - \exp(-z) - \frac{1}{z} \exp(-z) \right) =
n! \left( - (-1)^n \frac{1}{n!} - (-1)^{n+1} \frac{1}{(n+1)!} \right)

or


(-1)^{n+1} \left( 1 - \frac{1}{n+1} \right) = (-1)^{n+1} \frac{n}{n+1},

which is the desired result.

As an interesting aside, we observe that g(z,u,v) may be used to evaluate the following determinant of an n\times n matrix:

d(n) = \det(A_n) =
\begin{vmatrix}
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{vmatrix}.

where a, b \ne 0. Recall the formula for the determinant:

\det(A) = \sum_{\pi \in S_n} \sigma(\pi) \prod_{i=1}^n A_{i, \pi(i)}.

Now the value of the product on the right for a permutation π is a^f b^{n-f}\,, where f is the number of fixed points of π. Hence

 d(n) = b^n n! [z^n] g\left(z, -1, \frac{a}{b}\right)=
b^n n! [z^n] \exp \left(\frac{a-b}{b} z\right) (1+z)

which yields

 b^n \left(\frac{a-b}{b}\right)^n + b^n n \left(\frac{a-b}{b}\right)^{n-1} =
(a-b)^n + n b (a-b)^{n-1}

and finally

d(n) = (a + (n-1)b) (a-b)^{n-1}\,.

See also

External links

100 prisoners


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • 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 fields include coding theory,… …   Wikipedia

  • Permutation cipher — In classical cryptography, a permutation cipher is a transposition cipher in which the key is a permutation.To apply a cipher, a random permutation of size e is generated (the larger the value of e the more secure the cipher). The plaintext is… …   Wikipedia

  • List of permutation topics — This is a list of topics on mathematical permutations.*Alternating group *Alternating permutation *Bijection *Circular shift *Combination *Cycle index *Cycle notation *Cyclic order *Cyclic permutation *Derangement *Even and odd permutations… …   Wikipedia

  • Statistics — is a mathematical science pertaining to the collection, analysis, interpretation or explanation, and presentation of data. Also with prediction and forecasting based on data. It is applicable to a wide variety of academic disciplines, from the… …   Wikipedia

  • Resampling (statistics) — In statistics, resampling is any of a variety of methods for doing one of the following: # Estimating the precision of sample statistics (medians, variances, percentiles) by using subsets of available data (jackknife) or drawing randomly with… …   Wikipedia

  • Bootstrapping (statistics) — In statistics, bootstrapping is a modern, computer intensive, general purpose approach to statistical inference, falling within a broader class of resampling methods.Bootstrapping is the practice of estimating properties of an estimator (such as… …   Wikipedia

  • Exchangeable random variables — An exchangeable sequence of random variables is asequence X 1, X 2, X 3, ... of random variables such that for any finite permutation sigma; of the indices 1, 2, 3, ..., i.e. any permutation sigma; that leaves all but finitely many indices fixed …   Wikipedia

  • List of mathematics articles (R) — NOTOC R R. A. Fisher Lectureship Rabdology Rabin automaton Rabin signature algorithm Rabinovich Fabrikant equations Rabinowitsch trick Racah polynomials Racah W coefficient Racetrack (game) Racks and quandles Radar chart Rademacher complexity… …   Wikipedia

  • Cycle index — In mathematics, and in particular in the field of combinatorics, cycle indices are used in combinatorial enumeration when symmetries are to be taken into account. This is particularly important in species theory. Each permutation π of a finite… …   Wikipedia

  • Stirling numbers of the second kind — In mathematics, Stirling numbers of the second kind, together with Stirling numbers of the first kind, are one of the two types of Stirling numbers. They commonly occur in the study of combinatorics, where they count the number of permutations.… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”