Probability that two random permutations of an $n$-set commute?

From this MathOverflow question:

It is well known that two randomly chosen permutations of $n$ symbols commute with probability $p_n/n!$ where $p_n$ is the number of partitions of $n$. -- Benjamin Steinberg

Unfortunately, it's not well known to me. Can I get a reference or link to this result? Or a proof, if it's simple enough.

(Google doesn't work where I am; I tried Binging two random permutations commute but it only gives the MathOverflow link.)

I need this result for a secret sharing scheme I'm currently analyzing.


It's a simple matter of combining two other well-known facts:

  1. In any finite group $G$, the probability that $a,b$ commute, with $(a,b)\in G\times G$ chosen uniformly at random, is $k/G$, where $k$ is the number of conjugacy classes of $G$.
  2. Conjugacy classes in $S_n$ correspond to cycle types, which correspond to integer partitions.

For fact one, see the very end of my answer here. One easily finds proofs and discussions of the second fact googling "conjugacy classes symmetric group," for instance this one.


Just to add a bit more detail to blue's answer, for a finite group $G$, the probability that two randomly chosen elements commute is

$$\frac{1}{|G|^2}\sum_{g \in G} |C_G(g)| = \frac{1}{|G|}\sum_{g \in G} \frac{1}{|{\rm Cl}(g)|} = \frac{k}{|G|}$$

where $k$ is the number of conjugacy classes of $G$.