I was asked the following problem:
Given a coin with $\displaystyle P( H) =p,\ P( T) =1-p$, what is the expected number of tosses until we receive two $\displaystyle H$ in a row?
I may use the fact that the expected number of tosses until the first $\displaystyle H$ is $\displaystyle \frac{1}{p}$.
My solution:
Let's denote $\displaystyle X_{2} =number\ of\ tosses\ until\ HH\ ( including\ the\ HH)$.
We want to find $\displaystyle E[ X_{2}]$.
At the same time, let's denote $\displaystyle X_{1} =number\ of\ tosses\ until\ H\ ( including\ H)$.
From the given we know that $\displaystyle E[ X_{1}] =\frac{1}{p}$.
Let's now try to simplify the expression $\displaystyle E[ X_{2}]$ with the Law of Total Probability.
Let's denote two events:
$\displaystyle A=after\ the\ 1^{st} \ H\ appears,\ the\ next\ toss\ is\ an\ H$.
$\displaystyle A^{c} =after\ the\ 1^{st} \ H\ appears,\ the\ next\ toss\ is\ a\ T$.
Let's also assume that the number of tosses until the first $\displaystyle H$ is some number $\displaystyle r$.
Since every toss is independent from each other, we know that $\displaystyle P( A) =P( H) =p$.
At the same, from the same reason, we will get $\displaystyle P\left( A^{c}\right) =P( T) =1-p$.
From the \ Law of Total Probability then, we can define:
$\displaystyle E[ X_{2}] =P( A) \cdotp E[ X|A] +P\left( A^{c}\right) \cdotp E\left[ X|A^{c}\right]$.
$\displaystyle =p\cdotp E[ X|A] +( 1-p) \cdotp E\left[ X|A^{c}\right]$.
But,
• $\displaystyle E[ X|A]$ = the expected number of tosses until the first HH, if we know that we had exactly $\displaystyle r$ tosses until the first $\displaystyle H$, and after that we had an $\displaystyle H$.
Basically, this means we received $\displaystyle HH$ consecutively for the first time! So we will stop tossing here.
The number of tosses, in this case, will be is $\displaystyle r+1$.
We know the expected value of $\displaystyle r$ is $\displaystyle E[ X_{1}] =\frac{1}{p}$.
So: $\displaystyle E[ X|A] =\frac{1}{p} +1$.
• $\displaystyle E\left[ X|A^{c}\right]$ = the expected number of tosses, if we know that we had exaclty $\displaystyle r$ tosses until the first $\displaystyle H$, and after that we had a $\displaystyle T$.
Also, in this case, we tossed the coin $\displaystyle r+1$ times, but we won't be stopping, since we didn't achieve the $\displaystyle HH$ consecutively. The opposite, we are left facing the same problem recursively. Each toss is independent from the previous one, so after the $\displaystyle r+1$, we have to "start over", and have again $\displaystyle E[ X_{2}]$ expected tosses.
So: $\displaystyle E\left[ X|A^{c}\right] =\frac{1}{p} +1+E[ X_{2}]$.
Overall plugging into our initial equation we get:
$\displaystyle \begin{array}{{>{\displaystyle}l}} E[ X_{2}] =p\cdotp \left(\frac{1}{p} +1\right) +( 1-p) \cdotp \left(\frac{1}{p} +1+E[ X_{2}]\right)\\ =1+p+\frac{1}{p} +1+E[ X_{2}] -1-p\cdotp E[ X_{2}]\\ \Rightarrow \\ p\cdotp E[ X_{2}] =\frac{1}{p} +1\\ \Rightarrow \\ E[ X_{2}] =\frac{1+p}{p^{2}} . \end{array}$
I'm confident this solution is correct, by looking at this other question: Expected value of number of trials to get k SUCCESSIVE successes.
I basically plugged in my numbers into their solution.
Despite this, they used a different method it seems in the first passage, which I don't really understand where it's derived. At the same time, I feel like my answers use a lot of words especially for the cases of $\displaystyle E[ X|A] ,\ E\left[ X|A^{c}\right]$. I hoped to have some formula to use instead of having to explain the solution "logically".
Any advice?