Mean and Variance of Number of Heads

There are 2 coins in a box: the first has probability $$\frac 13$$of showing heads, the second has probability $$\frac14$$of showing heads. You choose one coin and you flip it $$n$$ times (you don’t know which coin you picked). Let $$X$$ be the number of heads shown by the coin you chose over $$n$$ flips. Find the mean and variance of $$X$$.

I found that $$E(X)=\frac{7n}{24}$$. To find $$Var(X)$$, I tried using the Law of Total Variance. I defined $$Y$$to be the event that coin 1 is chosen. Then $$Var(X)=E[Var(X|Y)]+Var[E(X|Y)]=E[n*\frac 13*\frac 23]+Var[n*\frac 13]=\frac 29$$ because since $$n$$ is fixed, the variance is zero. However this was incorrect. Where did I go wrong?

In Law of Total Variance, $$Y$$ is a random variable. So for simplicity the definition should be like

$$Y = \begin{cases} 1 & \text{if Coin 1 is chosen} \\ 0 & \text{if Coin 2 is chosen} \end{cases}$$

And thus $$Var[X \mid Y] = \begin{cases} \displaystyle n \times \frac {1} {3} \times \frac {2} {3} = \frac {2n} {9} & \text{if} & Y = 1 \\ \displaystyle n \times \frac {1} {4} \times \frac {3} {4} = \frac {3n} {16} & \text{if} & Y = 0 \end{cases}$$

You may write this compactly as

$$Var[X \mid Y] = \frac {2n} {9} Y + \frac {3n} {16}(1 - Y)$$ The expectation will be $$E[Var[X \mid Y]] = \frac {2n} {9} \times \frac {1} {2} + \frac {3n} {16} \times \frac {1} {2} = \frac {59n} {288}$$

as the question presumed assumed both coins are equally-likely to be chosen.

Similarly, $$E[X \mid Y] = \frac {n} {3} Y + \frac {n} {4} (1 - Y) = \frac {n} {4} - \frac {n} {12} Y$$ $$Var[E[X \mid Y]] = \frac {n^2} {12^2} \times \frac {1} {4} = \frac {n^2} {576}$$

Therefore,

$$Var[X] = \frac {59n} {288} + \frac {n^2} {576}$$

• That makes sense, thanks for clarifying. Alternatively, is it correct to say $Var(X) = np(1-p)$ where we plug in $\frac {7}{24}$ for $p$? i.e. $Var(X)=n*\frac {7}{24}*\frac{17}{24}$? Apr 15, 2020 at 2:27