# (Conditional) coin flips mean and variance

Roll a fair die to obtain a random number $$1 ≤ n ≤ 6$$, then flip a fair coin $$n$$ times. Let $$X$$ be the random variable that expresses the number of heads in the coin flips. Find the mean and variance of $$X$$.

Since the coin flips are Bernoulli trials, the expected number for heads ($$H$$) and tails ($$T$$) are $$\mathbb{E}[H]=\mathbb{E}[T]=n/2$$.

Furthermore, $$H$$ (and $$T$$) is distributed as per the binomial distribution, which has mean $$n/2$$ and variance $$n/4$$, ($$n\in\{1,2,3,4,5,6\}$$).

I don't know how to combine this with the outcome of the die roll. I have very elementary knowledge with probability and statistics, but I know, at least, that the coin tosses are independent of any other event.

(This is a problem I found in a Facebook group - not homework or anything).

Thank you!

We have $$N \sim Unif\{1,6\}$$, $$X|N \sim Bin(N, \frac12)$$

By law of total expectation:

$$E[X]=E[E[X|N]]=E\left[ \frac{N}2\right]=\frac12 E[N]=\frac12 \cdot \frac{1+6}{2}=\frac74$$

Also, by the law of total variance, we have

\begin{align}Var(X) &= E[Var(X|N)]+Var(E[X|N]) \\ &=\frac14E\left[N\right]+\frac14Var(N)\\ &=\frac14 \cdot \frac72 + \frac14 \cdot \frac{6^2-1}{12}\end{align}

• Thank you very much; I would appreciate though a few more details, because, like I said, I only have very elementary knowledge of probabilities / statistics. I am quite good at combinatorics (because they are easy to understand and visualize) but statistics is not my strong point! Jan 10, 2022 at 10:07
• Hi, which steps is confusing? Jan 10, 2022 at 10:35
• I understand that $N$ follows uniform distribution in $\{1,6\}$ and that $X|N \sim Bin(N, \frac12)$, but I don't understand the rest, about $E[X]$ and variance, that is, how we are going to do the calculations. Thank you!! Jan 10, 2022 at 10:43
• I used the law of total expectation and the law of total variance. Perhaps read those posts first? Jan 10, 2022 at 10:50
• Maybe you should add $\mathsf P(X=0\mid N=1)$ for all values of $X$ and $N$? Jan 10, 2022 at 11:04