# Expectation recursively

Let $x_n$ be the expected number of coin flips (with probability $p$ for heads and $q$ for tails) for $n$ consecutive heads to occur. On one hand:

$$x_2 = q \cdot (1 + x_2) + p^2 \cdot 2 + p \cdot q \cdot (2 + x_2)$$

This leads to valid answer for $x_2$ (6 flips for a fair coin). On the other hand, I though I could also do it like this:

$$x_2 = q \cdot (1 + x_2) + p \cdot (1 + x_1)$$

$$x_1 = q \cdot (1 + x_1) + p \cdot 1$$

With $x(1) = 1/p$ again correct, but plugging this in the second expression for $x_2$ doesn't agree with the previous result.

I just followed the probability tree, didn't I? Where does error lie in my reasoning? And, if possible, how can one express $x_2$ in terms of $x_1$?

• I don't understand the second recursion. Yes, if you get $T$ then you now expect $1+x_2$. But if you get $H$ why would I expect $1+x_1$?
– lulu
Jun 22, 2017 at 11:06
• Note: the second recursion would be correct if you were asking "find the expected number of tosses required to get two Heads, not necessarily consecutive."
– lulu
Jun 22, 2017 at 11:14
• @lulu I can see I should replace $x_1$ with the conditioned expectation of getting two consecutive heads given the history of one head. But, can I put $x_1$ in the second recursion? I think I need that for a more difficult problem.
– BoLe
Jun 22, 2017 at 11:19
• I don't see how. At any point (unless you are done) throwing $T$ resets you to the start, so at no point can you reduce to simply needing to get one more $H$ at some point.
– lulu
Jun 22, 2017 at 11:22