5
$\begingroup$

The original question is shown below (References from the book of Introduction to Probability Models Tenth Edition):

A coin, having probability $p$ of landing heads, is continually flipped until at least one head and one tail have been flipped.

(a) Find the expected number of flips needed.

(d) Repeat part (a) in the case where flipping is continued until a total of at least two heads and one tail have been flipped.

I solve the question (a), but I am not sure my answer for question (d).

My answer is shown:

Let $N$ is the number of flips at least two head and one tail.

$$ \begin{align*} E[N] &= E[E[N|Y]]\\ &= E[N|HH]P(H)P(H) + E[N|HT]P(H)P(T) + E[N|TH]P(T)P(H) \end{align*} $$

$E[N|HH]$ means the first two are heads until a tail appeared;

$E[N|HT]$ means the first two are head and tail until a head appeared;

$E[N|TH]$ means the first two are head and tail a head appeared;

Let $E[T] = 1/q = 1/1-p$, $E[H] = 1/p$

Then, $E[N] = (2+1/q)pp + (2+1/p)p(1-p) + (2+1/p)p(1-p)$ ←Ans.

I am not sure whether I am right? Thanks a lot.

$\endgroup$
6
  • 1
    $\begingroup$ Plainly $E[N]\gt3$ but when $p=\frac12$ your final answer evaluates to $3$ so I don't think it can be right. $\endgroup$
    – bof
    Jan 21, 2020 at 6:52
  • 1
    $\begingroup$ I get $E[N]=q(1+\frac2p)+pq(2+\frac1p)+p^2(2+\frac1q)$. $\endgroup$
    – bof
    Jan 21, 2020 at 6:59
  • 1
    $\begingroup$ More neatly: $$E[N]=2\left(\frac1p-p\right)+\left(\frac1q-q\right)$$ $\endgroup$
    – bof
    Jan 21, 2020 at 13:20
  • $\begingroup$ Thanks a lot @bof , I am think what is my state (three conditions) wrong. $\endgroup$
    – Simon
    Jan 22, 2020 at 0:38
  • 1
    $\begingroup$ Did you miss the case where the first two flips are TT? $\endgroup$
    – bof
    Jan 22, 2020 at 14:47

2 Answers 2

3
$\begingroup$

Let $q=1-p$, $P=1/p$, and $Q=1/q$ for convenience. Some brief scratch paper work will verify that $pP=qQ=1$, $pQ=Q-1$, and $qP=P-1$.

Let's solve part (a) first, since it will be useful. Your first flip is either heads or tails. If it is heads, then we expect it will take $Q$ flips for the first tails to come up. If it is tails, then we expect it will take $P$ flips for the first heads to come up. Therefore, if $A$ is the expected number of flips before we see both heads and tails, then $$E[A]=p(1+Q)+q(1+P)\\=p+pQ+q+qP\\=1+(Q-1)+(P-1)=P+Q-1\\=(P-p)+(Q-q)$$

The same effort applies to the second part. Your first flip is either heads or tails. If it is heads, then we expect it will take $A$ flips to get another head and a tail. If it is tails, then we expect it will take $2P$ flips for two heads to come up. Therefore, $$E[B]=p(1+E[A])+q(1+2P)\\=p(P+Q)+q(1+2P)\\=pP+pQ+q+2qP \\=1+(Q-1)+q+2(P-1)\\=Q+q+2P-2\\=Q+q+2P-(2p+2q)\\=2P-2p+Q-q=2(P-p)+(Q-q)$$

Thanks to bof for recognizing that this collapses into an elegant form.

$\endgroup$
4
  • $\begingroup$ I think it simplifies to $E[B]=2(P-p)+(Q-q)$. $\endgroup$
    – bof
    Jan 21, 2020 at 13:29
  • $\begingroup$ If the second head comes on the $X$th flip, and the first tail comes on the $Y$th flip, and $Z=\min(X,Y)$, then $B=X+Y-Z$, so $$E[B]=E[X]+E[Y]-E[Z]=\frac2p+\frac1q-(1+p)=\frac2p+\frac1q-(2p+q)=2\left(\frac1p-p\right)+\left(\frac1q-q\right)$$ $\endgroup$
    – bof
    Jan 21, 2020 at 13:55
  • $\begingroup$ @bof I updated my solution to algebraically verify your conjecture. I really wasn't expecting it! $\endgroup$
    – user694818
    Jan 21, 2020 at 14:18
  • $\begingroup$ Thanks a lot to reply my question, I am learning it. : D Good understand~ $\endgroup$
    – Simon
    Jan 22, 2020 at 0:40
2
$\begingroup$

Let $p$ be the probability of heads $(0\lt p\lt1)$ and $q=1-p$ the probability of tails.

Define random variables $W,X,Y,Z$ as follows: $W$ is the number of flips until you have flipped at least two heads and one tail; the second head comes on the $X^\text{th}$ flip; the first tail comes on the $Y^\text{th}$ flip; and $Z=\min(X,Y)$. Then $W=\max(X,Y)=X+Y-\min(X,Y)=X+Y-Z$, so $$E[W]=E[X+Y-Z]=E[X]+E[Y]-E[Z]=\frac2p+\frac1q-(1+p)$$$$=\frac2p+\frac1q-(2p+q)=2\left(\frac1p-p\right)+\left(\frac1q-q\right)=\frac2p+\frac{p^2}q.$$


More generally, if $W_{m,n}$ is the number of flips until you have flipped at least $m$ heads and $n$ tails, $$E[W_{m,n}]=\frac mp+\frac nq-\sum_{i=0}^{m-1}\sum_{j=0}^{n-1}\binom{i+j}ip^iq^j$$ and in particular $$E[W_{m,1}]=\frac mp+\frac{p^m}q.$$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .