2

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 exactly $k$ of the party members receive their own hats back?

abhishek
  • 901
  • What did you do wrong? You appear to have calculated $P(E_1E_2E_3\cdots E_k)-P(E_1E_2\cdots E_{k+1})+P(E_1E_2\cdots E_{k+2})-\cdots$ and had not taken the summations into account. This should have been $\color{red}{\sum\limits_{i_1<i_2<\cdots <i_k}}P(E_{i_1}E_{i_2}\cdots E_{i_k}) - \cdots$ – JMoravitz Aug 09 '20 at 16:14
  • $P(E_{i_1}E_{i_2}\dots E_{i_n}) = \frac{(N-n)!}{N!}$ and $\color{red}{\sum\limits_{i_1<i_2<\cdots <i_k}}P(E_{i_1}E_{i_2}\cdots E_{i_n}) = \binom{N}{n}\frac{(N-n)!}{N!} = \frac{1}{n!}$,is this not correct? – abhishek Aug 09 '20 at 16:39
  • Note: the question has been changed, so that it becomes the question for which an answer has been posted. subsequently, the question that I wanted to ask has been moved here---->https://math.stackexchange.com/q/3785857/415432 – abhishek Aug 11 '20 at 09:11

1 Answers1

5

The "hat problem" is really getting the number $D_n$ of derangements of $\{1, 2, \dotsc, n\}$. What you are asking is the number of permutations with exactly $k$ fixed points. Now a permutation with exactly $k$ fixed is constructed by:

  • Pick the $k$ fixed points, there are $\binom{n}{k}$ ways to do so
  • The other $n - k$ elements are not on their places, i.e., they form a derangement of $n - k$ elements, i.e., $D_{n - k}$.

Total is just $\binom{n}{k} D_{n - k}$

vonbrand
  • 27,812