I have this problem at hand and have no idea on how to approach it. Any leads/solution would be appreciated.
You roll a fair $6$-sided die, and flip a coin n times where n is the number on the die. If $H$ refers to the number of heads observed after n coin flips, find
- $E[H|n]$ and $\operatorname{Var}(H|n)$ for $n$ in set ${1,2,3,4,5,6}$
- Find $E[H]$ and $\operatorname{Var}(H|n)$
Once $D=d$ is fixed, you just need to focus on the outcome of the coin flips (which is random).
Let's do one example for $d=3$ and you can fill in the rest. Let $H_d = H|d$ be the random variable that denotes the number of heads in $d$ coin tosses. You have:
$P(H_d=0) = (1/2)^3$ (TTT)
$P(H_d=1) = {3 \choose 1} (1/2)^3$ (HTT, THT, TTH)
$P(H_d=2) = {3 \choose 2} (1/2)^3$ (HHT, THH, HTH)
$P(H_d=3) = (1/2)^3$ (HHH)
Now you can compute the expected value as $(1/2)^3 \left( 0 \times 1 + 1 \times {3 \choose 1} + 2 \times {3 \choose 2} + 3 \times 1\right) = 1.5$.
Similarly you can compute the second moment and variance.
To put it together, you can compute:
$E[H] = \sum_{d=1}^6 E[H|D=d]P(D=d)$, i.e. the law of total expectation.