2

Question:
At a party $n$ people toss their hats into a pile in a closet. The hats are mixed up, and each person selects one at random. What is the expected number of people who select their own hats?

My Attempt:
Note, $$E(X) = \sum_{s\in S} p(s)X(s)$$

  • $E(x)$ is the expected value.
  • $p(s)$ is the probability of event $s$.
  • $S$ is the sample space.
  • $X(s)$ is the random variable.

The probability of one person picking his/her hat is $\dfrac{1}{n}$, two person picking their hat is $\dfrac{1}{n}\dfrac{1}{n-1}$. Let $n$ be the number of people, let $P(n, r)$ be number of $r-permutation$ in $elements$. to generalize,

$$p(s) = \dfrac{1}{P(n, s)}$$ where $s$, the sample is the number of people who picked their own hat.

Before I plug it all in to the $E(X)$ equation, the random variable is $X(s) = s$, or simply an identity function. My expected value formula is,

$$E(X) = \sum_{s\in S} \dfrac{1}{P(n, s)}*s$$

$$E(X) = \sum_{s=1}^{n} \dfrac{1}{P(n, s)}*s$$

Is this anywhere right? If I'm on track, how do I show what it equals to? The answer key said it should equal to one, but I'm lost from here.

JoeyAndres
  • 1,279
  • See also http://math.stackexchange.com/questions/627913/question-on-the-hat-check-problem –  Jul 23 '14 at 18:19
  • ... where Did's Answer explains the result $E(X)=1$ quite incisively. – hardmath Jul 23 '14 at 18:39
  • @hardmath in a book called Discrete Mathematics and Its Applications 4th edition (1999). – JoeyAndres Jul 23 '14 at 18:41
  • I'm justing pointing out your Question has already been answered in the link Byron provided. (Did being a user's name!) – hardmath Jul 23 '14 at 18:42
  • @hardmath Goodness, this is embarassing. I guess this is a duplicate. Since you guys have tons of reputation, can you guys delete this question? – JoeyAndres Jul 23 '14 at 18:45
  • Duplicates are not a bad thing, you've asked a good Question. The reason we close Duplicates but don't delete them is because they help the search engine (human or computer) to find good content. – hardmath Jul 23 '14 at 18:48

2 Answers2

1

The number of combinations for exactly $k$ out of $n$ people to select the correct hat is:

$ C_{n,k}= \begin{cases} \displaystyle[\frac{n!}{e}] & \text{$k=0$}\\ \displaystyle\binom{n}{k}\cdot{C_{n-k,0}} & \text{$k>0$}\\ \end{cases} $


So the probability that exactly $k$ out of $n$ people will select the correct hat is:

$\displaystyle{P_{n,k}=\frac{C_{n,k}}{n!}}$


Hence the expected number of people to select the correct hat is:

$\displaystyle\sum\limits_{k=1}^{n}k\cdot{P_{n,k}}$

barak manos
  • 43,599
  • @JoeyAndres: Please note the slight correction I applied in the answer (after you've accepted it). – barak manos Jul 23 '14 at 18:25
  • Forgive me, $\frac{\binom{n}{1}(n-1)!}{n!} = \frac{\frac{n!}{(n-1)!1!}(n-1)!}{n!} = 1$? I may be dyslexic. – snar Jul 23 '14 at 18:50
  • @snarski: Yes, $E(X)=1$. – hardmath Jul 23 '14 at 19:11
  • @snarski: You're absolutely right! The answer was ill-formed (yet, still up-voted and accepted). I've hopefully corrected it. Can you please review? If still wrong, then I'll remove it. Thanks. – barak manos Jul 24 '14 at 05:26
  • @hardmath: The answer was ill-formed (yet, still up-voted and accepted). I've hopefully corrected it. Can you please review? If still wrong, then I'll remove it. Thanks. – barak manos Jul 24 '14 at 05:26
  • I think the probabilities of exactly $k$ people getting their hats back are not right. Consider the cases of exactly one person, which amounts to choosing 1 of $n$ as your formula shows, but then having the remaining $n-1$ people not getting their hats, i.e. the derangements of $n-1$ things. For modestly large $n$ this should be close to $(n-1)!/e$, where $e$ is the base of natural logarithms. However you give $(n-2)!$ for that factor. Checking for $n=5$, there are 9 derangements of four things, so the probability should be $5*9/120 = 3/8$. – hardmath Jul 24 '14 at 11:54
  • @hardmath: For $n=5,k=1$, there are the following arrangements: With $1$ placed correctly and all the rest placed incorrectly, we have $9$ options - $13254,13452,13524,14253,14523,14532,15234,15423,15432$. So I guess that in total we have $45$ options out of $120$ to place exactly $1$ item correctly. Indeed, $\frac{45}{120}\neq\frac{1}{4}$, so my answer is wrong, and I will remove it soon (as soon as you read this comment). Thanks. – barak manos Jul 24 '14 at 12:21
  • You've given the problem a lot of thought, and I respect your call as to whether to delete or edit the Answer. Feel free to use some of the links to the other Questions to streamline any revision. – hardmath Jul 24 '14 at 12:26
  • @hardmath: Thank you. I am unable to remove this answer anyway, because it has been accepted by OP. – barak manos Jul 24 '14 at 13:42
  • Here is a correct solution I learned from Ross' First Course. Fix any $k$ people. The probability those (and only those) $k$ people choose their own hat is $P(k \text{ people choose their hat }|\text{ no one else chooses their own hat})P(\text{no one else chooses their own hat})$. This is $\frac{1}{n}\dots\frac{1}{n-k+1}p_{n-k},$ where $p_{n-k}$ is the probability of the remaining $n-k$ people do not choose their own hat among the $n-k$ hats that belong to them. Thus we need to find $p_k$ for $k \geq 1$. – snar Jul 24 '14 at 15:28
  • Let $N$ be the event that no matches occur among $n$ people (so $p_n = P(N)$) and let $S_1$ be the event that the first person selects his own hat. Since $P(N | S_1) = 0$, $p_n = P(N | S_1^c)P(S_1^c) = P(N | S_1^c)\frac{n-1}{n}.$ If $S_1^c$ occurs, among the $n-1$ remaining people, one (call him $X$) has no matching hat, and there is one leftover hat ($L$). $$P(N | S_1^c) = P(X\text{ gets }L\cap\text{no remaining ppl get their hat} |S_1^c) + P(X\text{ doesn't get }L \cap \text{ no remaining ppl get their hat} | S_1^c)$$ by disjointness of events. – snar Jul 24 '14 at 15:40
  • If we think of $L$ as belonging to $X$, then the second term on the RHS is just $p_{n-1}$. The first term has probability $\frac{1}{n-1}p_{n-2}$. Thus, $p_n = p(N | S_1^c)\frac{n-1}{n} = \frac{n-1}{n}p_{n-1} + \frac{1}{n}p_{n-2}$. Since $p_1 = 0, p_2 = 1/2$, we find $p_n = \frac{1}{2!} - \frac{1}{3!} + \dots + \frac{(-1)^n}{n!}.$ Going back to the first comment, there are $\binom{n}{k}$ ways of selecting $k$ people. Thus, the prob of exactly $k$ matches is $\binom{n}{k}\frac{(n-k)!}{n!}p_{n-k} = \frac{1}{k!}\sum_{i=2}^{n-k} \frac{(-1)^i}{i!}$. For the expectation, sum. – snar Jul 24 '14 at 15:48
0

The chance of picking your own hat at random out of a stack of $m$ hats $P_{m} = 1/m$.

If you assume all people take turns picking a hat at random the $k$th person of $n$ total persons (and hats) has a chance of $P_{n-k+1} = \frac{1}{n-k+1}$.

If $n$ persons pick their hats out of a stack of $l$ hats the expected value of people picking their own hat is $E_{n,l} = \displaystyle\sum_{k=1}^{n} P_{l-k+1} = \displaystyle\sum_{k=1}^{n} \frac{1}{l-k+1}$. Note that $l \geq n$.