If we flip a fair coin until we get heads, what is the variance of the number of flips to do this?

My attempt is:

$$E(flips):=Y=1\times P(H)+(1+Y)\times P(T)$$ $$\Rightarrow Y=\frac{1}{2}+\frac{1+Y}{2}$$ $$\Rightarrow Y=2$$ I know this is correct. Now we attempt to compute:

$$E(flips^2):=X=1^2\times P(H)+(\sqrt{X}+1)^2\times P(T)$$

$$\Rightarrow X=\frac{1}{2}+\frac{(\sqrt{X}+1)^2}{2}$$

$$\Rightarrow X=2(2+\sqrt 3)$$

I know the right answer is $E(flips^2)=6$, but I'm not sure how to solve it using this recursive strategy, as the above seemed most natural to me.*

*ie take the expected value $X$, square root it to get the number of flips (not squared), add one, then square it again.

up vote 4 down vote accepted

You are essentially using the Law of Total Expectation; see the accepted answer here for a review: https://math.stackexchange.com/questions/521609/finding-expected-value-with-recursion.

Let $N$ be the number of flips required until the first heads appears, and let $H_1$ be the indicator of a heads on the first flip; i.e. $H_1 = 1$ if the first flip is heads and $H_1 = 0$ if it is tails. We will compute $E(N^2)$ using the Law of Total Expectation: $$E(N^2) = E(E(N^2 | H_1)).$$ The conditional expectation $E(N^2 | H_1)$ is a random variable; in particular it is a function of $H_1$. Let's find its distribution. Conditional on $H_1 = 1$ (i.e. when the first flip is heads), the number of flips until heads appears will of course be one, so $E(N^2 | H_1 = 1) = 1^2$. Conditional on $H_1 = 0$ (when the first flip is tails), the number of flips until heads appears will be one more than in the unconditional case, hence the conditional expectation is $E(N^2 | H_1 = 0) = E((N + 1)^2) = E(N^2) + 2E(N) + 1$. Thus \begin{align} E(N^2) & = E(E(N^2 | H_1)) \\ & = 1^2 \cdot \frac{1}{2} + (E(N^2) + 2E(N) + 1)\cdot 1/2 \\ & = \frac{1}{2} + (E(N^2) + 2(2) + 1)\cdot 1/2. \\ \end{align} Solving the equation, we find that $E(N^2) = 6$ and then $Var(N) = 6 - 2^2 = 2$.

The excellent answer by Gordon Honerkamp-Smith already answers your question, but I will give you an alternative derivation that goes directly to the distributional form. Let $N$ be the number of flips until the first head appears. This random variable has a geometric distribution:

$$N \sim \text{Geom}(p = \tfrac{1}{2}).$$

Using the known form for the variance of this distribution, you get:

$$\mathbb{V}(N) = \frac{1-p}{p^2} = \frac{1-\tfrac{1}{2}}{(\tfrac{1}{2})^2} = \frac{\tfrac{1}{2}}{\tfrac{1}{4}} = 2.$$

  • 1
    +1. My thoughts exactly, I immediately thought: "This is a geometric, let's plug the numbers!" – usεr11852 Oct 22 at 23:09

Although this doesn't follow your recursive approach, you can use the geometric distribution's properties here.

You have $X$, which I will refer to as $flips$ from now on, is distributed according to $Geometric(p=0.5)$.

Recall the definition of Variance, $Var(flips)=E(flips^2) + [E(flips)]^2$

where, $Var(flips)=\frac{1-p}{p^2}$ and $E(flips)=\frac{1}{p}$.

Thus, $E(flips^2)=Var(flips) + [E(flips)]^2 = 2+4 = 6$.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.