# Why can this question be treated as a question with geometric random variable without any modifications?

In an infinite sequence of flipping a fair coin - $$0.5$$ probability to get heads/tails. (every flip is independent from the others).
What is the expected value of number of flips until we get Heads then Tails?

My Attempt:
I tried to think about the event HT as my R.V success. So let $$X$$ be the number of flips until we get HT.
The probability to get HT in a row is $$\frac{1}{4}$$, as we need the coin to land on H and then immediately on T.
But I thought to myself that a geometric RV doesn't really count those two as two flips, so I thought that for example:
TTTHHHT -> My random variable $$X$$ would be $$6$$.
So I set $$Y=X+1$$ and my answer was $$E(X+1)=4+1=5$$.

But turns out the real answer is $$4$$. Why my method is wrong? where does my logic/understanding fall?
Is it that $$X$$ is just the answer for this problem? but I can't see how that's right, or maybe I have issues in my geometric random variable understanding.
Would appreciate any help, Thanks in advance!

• I did not understand how you counted $5$ Commented Oct 2, 2021 at 18:39
• "real answer" from where? Commented Oct 2, 2021 at 18:43
• @herbsteinberg The writer of the question, the final answer provided with it.. Commented Oct 2, 2021 at 18:52
• OK I see now but the random variable will count $HT$ as $2$. Commented Oct 2, 2021 at 19:00
• But $E(X)$ for two heads in a row is $6$ Commented Oct 2, 2021 at 19:18

Let $$\xi_i$$ be the result of the i-th coin toss, and let $$X = \min_{n} \{n >0: \xi_n = T, \xi_{n-1}-H\}$$ You can use the law of total probability, then you have $$\mathbb E(X) = \mathbb E(X|\xi_1=H) \mathbb P(\xi_1=H) + \mathbb E(X|\xi_1=T) \mathbb P(\xi_1=T)$$ We can calculate the conditional expectations. $$X|\xi_1=H \sim 1+Geo(1/2) \implies \mathbb E(X|\xi_1=H) = 1+2=3$$ $$E(X|\xi_1=T) = 1 + E(X)$$ If we substitute the results in the above equation, we get: $$\mathbb E(X) = 3 \frac 12 + \mathbb (E(X)+1) \frac 12$$ $$\mathbb E(X) = 4$$

Here is how I would do it. Say $$X$$ is the event of getting $$H, T$$ in a row. Based on the first flip, we have two cases -

$$i$$) The first flip is $$H$$ - Then we are seeking the next flip to be a $$T$$. If we get $$T$$, we are done but if we get $$H$$, we are again looking for a $$T$$ and so on.

$$ii$$) The first flip is $$T$$ - We spent a flip and we are again back to where we started, that is seeking $$H, T$$.

So, $$E(X) = 1 + \frac{1}{2} E(X) + \frac{1}{2} E(T)$$

Now we know $$E(T) = 2$$

So, $$E(X) = 4$$