[Math] A coin flipped until two of the most recent three flips are Head. Let $N$ denote the number of flips. Find $E(N)$

probability

A coin for which $P(Head)=0.6$ is successively flipped until two of the most recent three flips are Head. Let $N$ denote the number of flips. Find $E(N)$.

What I did:

Let X denote the first time a Head appears. Then $E(N)=E[E(N|X)]=\sum_{i=1}^{\infty}E(N|X=i)=\sum_{i=1}^{\infty}NP_{N|X=i}(n)=\sum_{i=1}^{\infty}N\frac{P(N,X=i)}{P_{X}(X=i)}$

Does anyone could help me to continue doing this problem?Thanks!

Best Answer

A different approach, still using conditional expectation ...

Let $p=P(H)$ and $q=P(T)$. Condition on the result of the first two flips:

\begin{eqnarray*} E(N) &=& 2 + E(N\vert HH)P(HH) + E(N\vert HT)P(HT) + E(N\vert TH)P(TH) + E(N\vert TT)P(TT) \\ &=&2 + p^2 E(N\vert HH) + pqE(N\vert HT) + pqE(N\vert TH) + q^2E(N\vert TT) \end{eqnarray*}

For easier notation, let $E=E(N)$ and also $E_{HH}=E(N\mid HH)$, and so on. Then we have:

$$E = 2 + p^2 E_{HH} + pqE_{HT} + pqE_{TH} + q^2E_{TT}.$$

Next we have:

\begin{eqnarray*} E_{HH} &=& 0 \qquad\text{since we have two heads} \\ && \\ E_{TT} &=& E \qquad\text{since after two tails it's like starting over} \\ && \\ E_{HT} &=& 1 + (0\cdot P(H) + E_{TT}\cdot P(T)) \qquad\text{(next H gives HTH and we are done)} \\ &=& 1 + qE \\ && \\ E_{TH} &=& 1 + (E_{HH}\cdot P(H) + E_{HT}\cdot P(T)) \\ &=& 1 + q(1 + qE) \\ &=& 1 + q + q^2E. \\ \end{eqnarray*}

Substitute these into the above equation, giving

\begin{eqnarray*} E &=& 2 + pq(1+qE) + pq(1+q+q^2E) + q^2E \\ (1-pq^2 - pq^3-q^2)E &=& 2 + 2pq + pq^2 \\ E &=& \dfrac{2 + 2pq + pq^2}{1-pq^2 - pq^3-q^2}. \\ \end{eqnarray*}

Substituting $1-p$ for $q$, this simplifies to:

$$E(N) = \dfrac{1+2p-p^2}{p^2(2-p)}.$$

For $p=0.6$ we have $E(N) \approx 3.65$.