Say you take all 12 eggs out of an egg carton, randomly permute them, and put them back in. How many eggs come back to their original place, on average?
One!
What's the probability that exactly one gets back to its original place? This is a lot harder, because unlike the first question it really depends on the number "12". But the answer is close to 1/e. And if we did it for 100 eggs, or a million, the answer would get even closer to 1/e.
What's the probability that exactly n eggs each get back to their original place? Now things get really interesting. The answer is complicated, but again it simplifies a lot in the limit where we permute a huge number of eggs. Then the answer approaches 1/e divided by n factorial.
What's interesting about that? It's the same as the answer to *this* question: if you're standing in the rain, and on average one raindrop lands on your head every second, what's the probability that in one second exactly n raindrops land on your head? At least this is true if raindrops are falling randomly in the most reasonable way - a so-called 'Poisson distribution'.
So random permutations are connected to Poisson distributions. And the connection goes a lot further than I've explained so far.
I've been trying to understand this better and better. The formulas I'm trying to understand are already known, but I've been proving them using category theory:
https://golem.ph.utexas.edu/category/2024/12/the_cycle_length_lemma.html
This gives a deeper outlook: instead of just proving an equation about probabilities, we can show that two categories are equivalent, and this has the equation as an easy spinoff. All the fun facts I just listed, and more, become facts about categories!

