Random Permutations (Part 6)
Posted by John Baez
Now I’ll tackle a really fundamental question about random permutations — one whose answer will quickly deliver the solutions to many others!
Puzzle 7. What is the expected number of cycles of length in a random permutation of an -element set?
The answer is beautiful: it’s . More precisely, this holds whenever the question is reasonable, meaning .
Note that this answer passes a simple sanity check. If on average there’s cycle of length , cycles of length , and so on, the average number of elements in our -element set must be
Whew!
Before we show the expected number of cycles of length in a random permutation of an -element set is , let’s see how knowing this lets us answer some other questions we’ve met.
- What’s the expected number of fixed points of a random permutation?
Since a fixed point is a cycle of length , the answer is . We’ve already seen this in Part 1. There we got it the hard way, by computing the probability that a permutation has fixed points. But I hinted that there’s a much easier way. Here it is: since the probability that a random permutation of an -element set fixes any given point is , the expected number of fixed points is .
- What’s the probability that a random permutation of an -element set has a cycle of length , assuming ?
Since is more than , there can be at most one cycle of length . Thus, the probability that such a cycle exists equals the expected number of such cycles! So, the probability must be . We already saw this in Part 4. Now we’re seeing a nice way to generalize this fact to , not by asking whether a cycle of length exists, but by asking the expected number of such cycles.
- What is the expected number of cycles in a random permutation of an -element set?
This was Puzzle 5 in Part 3. Since the expected number of cycles of length is , we can sum over and get the answer:
Asymptotically this is . Or, even better, it’s plus a correction that goes to zero as .
- If we choose an element of an -element set and random permutation of this set, what is the probability that the element lies in a cycle of length ?
This was Puzzle 8 of Part 3. Now I’m telling you that the expected number of cycles of length is . Since each contains elements, the expected number of elements of our set lying on cycles of length is . So, the probability that any element lies on a cycle of length is . It’s cool how this is independent of .
Okay, I hope you’re convinced by now that computing the expected number of cycles of length in a random permutation of an -element set is the key to understanding many things. Let’s do it!
Flajolet and Sedgewick do this using bivariate generating functions in Example III.9 of their book Analytic Combinatorics. I explained the basic method last time so now I’ll just use it.
We start by making up a functor
that assigns to the pair the set of all permutations of having exactly cycles of length . Note that here is being treated as a finite set, while and are just numbers.
The generating function of is defined by
Suppose we could compute this. How could we use this to answer our puzzle?
We want the expected number of cycles of length in a permutation of an -element set. Since the probability that a random permutation has cycles of length is
this expected number is
So this is the sum we need to compute.
But notice,
So, the expected number we want is the coefficient of in the power series for
Thus, to answer our puzzle, we should figure out , differentiate it with respect to , set , and read off the coefficient of .
For this, we’ll need a formula for :
Let’s see what this means! As soon as you understand what it means, you’ll know it’s true. That happens a lot in category theory.
Here is the species ‘being a cyclically ordered -element set’. We’ve already met the species
which is ‘being a cyclically ordered finite set’, and now we’ll define a species
which is ‘being a cyclically ordered finite set of cardinality ’. All these species can be seen as functors from to that don’t involve the second variable.
On the other hand, we have a functor
called ‘being the number 1’. This is defined by setting and for all . This can be seen as a functor from to that doesn’t involve the first variable.
It’s a bit hard for me to describe the functor
in plain English, mainly because I haven’t developed a vocabulary for functors the way I have for species! A species describes a type of structure you can put on a finite set; one of these functors describes a type of structure you can put on a finite set and a natural number. This one is ‘either your finite set is cyclically ordered and not of cardinality and your number is , or it’s cyclically ordered and of cardinality and your number is ’.
As a consequence
describes the following sort of structure on a finite set and a natural number. This structure is a way to chop the finite set into cyclically ordered pieces and simultaneously write the number as sum of ’s and ’s, but using a for each piece of cardinality , and a for every other piece. This is why we get
where is the set of all permutations of the set having exactly cycles of length .
That’s my best attempt at a purely verbal explanation of this isomorphism. Now let’s exploit it: it gives an equation between generating functions
which will let us compute .
To proceed, notice that
since there are ways to cyclically order a -element set. Similarly,
The whole point of is that
So, we get
In other words, this generating function is like that of , the species of cyclic orderings:
except that we’ve yanked out the term and stuck it back in multiplied by . That’s why it pays special attention to cycles of length .
From this we get
Now to answer our puzzle we differentiate this with respect to , set , and read off the coefficient of . That’ll be the expected number of cycles of length in a random permutation of an -element set!
Here we go:
As long as , the coefficient of in this power series is . But of course, we need for this whole calculation to make sense.
So whenever , the expected number of cycles of length in a random permutation of an -element set is . It’s a little jewel of mathematics.
Re: Random Permutations (Part 6)
You rhetorically asked:
…and answered…
That is beautiful!
Another way to say it is this: in a random permutation of an -element set, the expected number of -periodic points is .
Do you know of any direct way of seeing that the expected number of -periodic points in a permutation of elements should be independent of , for ?
E.g. why should the expected number of 3-periodic points in a permutation of 10 elements be the same as in a permutation of 100 elements?
For some reason this is reminding me of Barbier’s beautiful solution of the Buffon needle problem. But if I could put my finger on why, I could answer my own question!