Matching hat problem

combinatoricsdiscrete mathematicsprobability

I have a question on the famous hat matching problem. Here's the setup:
N people arrive at a party all of whom are wearing hats. We collect all the hats and then redistribute them. What is the probability that at least one of the party members receives his/her own hat?

My attempt:
I noticed we are looking for the probability that at least one party member has his/her own hat back, which in my head triggers the use of the complement rule.

Let A be the event that at least one person receives his/her own hat back. Then $A^c$ is the event that no one receives his/her own hat back.

$$P(A) = 1 – P(A^c)$$
In my head, $P(A^c)$ should be the probability that the first person doesn't receive his hat times the probability that the second person doesn't receive his hat and so forth…
$$P(A^c) = \frac{(N – 1)}{N}\frac{(N – 2)}{N-1}…$$
However continuing down this path, I noticed that for the last two people, the probability of the second to last person not getting his/her hat back is $\frac 12$ and the probability of the last person not getting his/her hat back is $\frac 02$ which doesn't make sense.

Obviously my solution is wrong mathematically, but I can't figure out why intuitively my answer is incorrect which seems to be a common trend for combinatorics problems for me. Any advice?

Best Answer

The first person avoid his own hat. Hence $N-1$ options.

What about the second person person? His number of option relies on whether the first person has chosen the hat of the second person. He might have $N-2$ options (if his hat wasn't chosen earlier) and $N-1$ options (if his hat has been chosen earlier).

Hence the formula for $P(A^C)$ is not correct.

A possible way to compute the quantity is by using inclusion-exclusion principle. Let $S_i$ be the set of permutation that fix the $i$-th item.

Then

$$|\bigcup_{i=1}^N S_i|=\sum_{i=1}^N(-1)^{i+1}\binom{N}{i}(N-i)!=N!\sum_{i=1}^N\frac{(-1)^{i+1}}{i!}$$

Divide by $N!$ to get the probability.