Hats at party problem: number of times people throw their hats… until they all get their own hats back

probabilitypuzzle

$n$ people are at party and they each have an identical hat. They do the following: they throw their hats toward the center of the room and then pick them up. People who got their own hats back leaves the room and the rest continue. What is the expected number of times $n$ people do "that", namely throw their hats and then pick them up, in order for all of them to leave?

So let $E(X_n)$ denotes the expected number of times that $n$ people has to throw the hats. Then $E(X_n)$ is $\sum_{i=0 \to n} E(X_{n-i})*P(F_i)$. Here $F_i$ denoted the number of people who got their hats back in the first round. Is this correct? or is this $E(X_n)$ is $\sum_{i=0 \to n} E(X_{n-i}+1)*P(F_i)$ correct? then what's next?

Best Answer

Let $F_n$ be the random variable that counts how many of the $n$ people got their hats back on the first round. We apply the law of total of expectation. We have

\begin{align} \Bbb E(X_n) &= \Bbb E \big(\Bbb E(X_n|F_n)\big) \\&= \sum_{k=0}^n \Bbb E(X_n|F_n = k)\cdot \Bbb P(F_n = k) \\&= \sum_{k=0}^n \big(1 + \Bbb E(X_{n-k})\big)\cdot \Bbb P(F_n = k).\tag{1} \end{align}

Notice that if $k$ people got the hat back on the first round $(F_n=k)$, then there are $n-k$ remaining people. The expected number of rounds for them will be $\Bbb E(X_{n-k})$, and we add $1$ to account for that first round when all $n$ people were participating.

EDIT: Notice of course that you can simplify it further, either by symbolic manipulation of the expression $(1)$ or by similar reasoning to the one above. We end up with

$$\Bbb E(X_n) = 1 + \sum_{k=0}^n \Bbb E(X_{n-k})\cdot \Bbb P(F_n = k).$$

Related Question