# Expected Value and Indicator Random Variable

In this ques P(1st person selects his own hat) = 1/N, but then the next person selects his own hat, he is picking from the pool of 'N - 1' hats.

Why do we treat P{Xi = 1} = 1\N for all i? Shouldn't it be only for i = 1?

Or is there an inherent assumption that one person picks a hat, notes whether he picked his own hat, and then puts it back?

One more ques, we are using the property that E($$\sum_{i=1}^{N} X_i$$) = $$\sum_{i=1}^{N} E(X_i)$$, to use this the joint pdf of $$X_i$$ i=1(1)N should be defined, again do we take it for granted that it is defined?

• It wasn't explicitly stated but it must be that each person takes a turn picking a hat and then throws the hat that they picked back in the mix after they pick it. But, you're right in that that should have been clearly stated. Your second question is not clear to me. Commented Jan 9, 2022 at 14:43
• It doesn't matter if they put their hat back or not. Still $1/N$. Commented Jan 9, 2022 at 14:52
• @mlofton Go through JKL's answer in this [link] (math.stackexchange.com/questions/3992251/…) He has used f(x,y) and we can use f(x,y) only if f(x,y) is defined. So my ques is along similar lines, whether f($x_1, x_2,..... x_n$) is defined in the example (the one I have attached)? Gunes' response answers that part as well. Commented Jan 9, 2022 at 15:46
• Instead of 'each', say 'any one'. See derangements. Notice that $E(X)=Var(X)=1.$ For $N > 10$ one has (approximately) $X \sim\mathsf{Pois}(\lambda=1),$ But not exactly, because $P(X = N-1) = P(X > N) = 0.$ Commented Jan 9, 2022 at 19:33

There are $$N!$$ situations, and for each $$i$$ (person), in only $$(N-1)!$$ of them , they take their own hat. This yields $$(N-1)!/N!=1/N$$.

Or, if you go step by step, which is harder, using total probability law, you could write

\begin{align}P(X_2=1)&=P(X_2=1|X_1=1)P(X_1=1)+P(X_2=1|X_1=0)P(X_1=0)\\&=\frac{1}{N-1}\frac{1}{N}+\frac{1}{N-1}\frac{N-2}{N}\\&=\frac{1}{N}\end{align}

For the second summand, the first person shouldn't take his/her own hat and also Person 2's hat because o/w the second person can't take its own hat, which leaves us with $$N-2$$ hats.

All the possibilities are finite, which makes everything trivial. So, you could count every possible combination and form up a joint probability table, which will define the joint distribution of these variables.

• Wow. That's so not intuitive to me. I understand the step by step approach you did but not the first approach. What do you mean that there are (N-1)! ways of each person getting their own hat ? $(N-1)! = (N-1)(N-2)(N-3)... \times 1$ which, to me. looks like all the ways each person would NOT get their own hat. Note that I believe that you are correct. I just want to understand the first approach since it's quicker. Thanks for interesting solution. Commented Jan 9, 2022 at 19:50
• and what's your definition of hobbyist ? :). seems like you're more than a hobbyist to me but I guess it depends on the definition. Commented Jan 9, 2022 at 19:52
• Let's say we're interested in person $i$. We give hat $i$ to person $i$, and distribute the remaining $N-1$ hats anyway you like, which can be done in $(N-1)!$. We're not interested if any other person got his/her own hat or not, only person $i$. Divide this by the total number of possibilities, $N!$, and you get $1/N$. I wrote hobbyist since I'm not an academician or these things are not in my daily work routine. Commented Jan 9, 2022 at 21:16
• now I get it. your explanation using the factorials was also just for one person. Neat.yeah, I don't know who would get to do this sort of thing in jobs, except some academics !!!!!! Interesting that it's $\frac{1}{N}$ even without replacement. I would think that the probabilities for each person would change ( when there was no replacement ) but I guess there's a cancelling out as one goes down the line that causes it to stay the same.The greater the value of $i$, the smaller the number of hats gets but the number of hats that couldn't be picked before i is greater. Commented Jan 10, 2022 at 0:23