Use indicator random variables to solve the following problem, which is known as the hat-check problem. Each of \(n\) customers gives a hat to a hat-check person at a restaurant. The hat-check person gives the hats back to the customers in a random order. What is the expected number of customers who get back their own hat?
The hat-check problem is a classic probability puzzle. Imagine checking your hat at a restaurant, but the hat-check person completely mixes them up and returns them randomly. How many people, on average, will get lucky and receive their own hat back?
Using Indicator Random Variables
For each customer \(i\) where \(1 \leq i \leq n\), we define an indicator random variable:
\[X_i = \begin{cases} 1 & \text{if customer } i \text{ gets their own hat back} \\ 0 & \text{otherwise} \end{cases}\]The total number of customers who get their own hat back is:
\[X = \sum_{i=1}^{n} X_i\]By linearity of expectation:
\[E[X] = E\left[\sum_{i=1}^{n} X_i\right] = \sum_{i=1}^{n} E[X_i]\]Computing the Probability
By Lemma 5.1 from the text, \(E[X_i] = \Pr\{\text{customer } i \text{ gets their own hat}\}\).
Since the hats are returned in a uniformly random order, customer \(i\) is equally likely to receive any of the \(n\) hats. Therefore:
\[\Pr\{\text{customer } i \text{ gets their own hat}\} = \frac{1}{n}\]This gives us:
\[E[X_i] = \frac{1}{n}\]The Surprising Result
\[\begin{align*} E[X] &= \sum_{i=1}^{n} E[X_i] \\ &= \sum_{i=1}^{n} \frac{1}{n} \\ &= n \cdot \frac{1}{n} \\ &= 1 \end{align*}\]The expected number of customers who get their own hat back is exactly 1, regardless of how many customers there are!
Interactive Simulation
See the remarkable constant in action! The simulation below shows that regardless of \(n\), the expected number of matches stays at 1: