Coin flips 2

Following up on my last post, here is an easier way to solve the “coin flips” problem. Let {N} be the number of flips until {r} consecutive heads and {T} the number of flips until the first tails. Then

\displaystyle  \mathbb E[T|N=k] = \begin{cases} k + \mathbb E[T],& k\leqslant r\\ r,& k>r \end{cases}

So

\displaystyle  \begin{aligned} \mathbb E[T] &= \mathbb E[\mathbb E[T|N]]\\ &= \sum_{k=1}^\infty \mathbb E[T|N=k]\mathbb P(N=k)\\ 			 &= \sum_{k=1}^r (k+\mathbb E[T])(1-p)p^{k-1} + \sum_{k=r+1}^\infty r(1-p)p^{k-1}\\ &= (1-p)\sum_{k=0}^{r-1}(k+1)p^k + (1-p)\mathbb E[T]\sum_{k=0}^{r-1} p^k + r(1-p)\sum_{k=r}^\infty p^k\\ &= \frac{(1-p)(1-(r+1)p^r + rp^{r+1})}{(1-p)^2} + (1-p)\mathbb E[T]\frac{1-p^r}{1-p} + r(1-p)\frac{p^r}{1-p}\\ &= \frac{1 - rp^r - p^r + rp^{r+1}}{1-p} + (1-p^r)\mathbb E[T] + rp^r, \end{aligned}

and hence

\displaystyle  \begin{aligned} \mathbb E[T] &= \frac1{p^r}\left(\frac{1 - rp^r - p^r + rp^{r+1}}{1-p} + rp^r \right)\\ &= \frac1{p^r}\left(\frac{1 + (1-p)rp^r - rp^r - p^r + rp^{r+1}}{1-p} \right)\\ &= \frac{1-p^r}{p^r(1-p)}. \end{aligned}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s