# Fair coin tosses until until two consecutive heads or two consecutive tails appear

A fair coin is tossed repeatedly and independently until two consecutive heads or two consecutive tails appear. Find the PMF, the expected value, and the variance of the number of tosses. Let X be a total number of tosses And it is a problem of geometric distribution.

1)The pmf is clear for me: $pmf = (1/2)^{k-1}$

The problem is with expected value:

2)My solution: $E[X] = 1/p = 2$

Solution of the book: $E[X] = E[Y] + 1 = 3$

I can't understand the book's solution. How we came to this? I need some explanation. Thanks.

• The p$\color{red}{\text{d}}$f is supported on $[2,+\infty]$, hence we are computing the expected value of a shifted geometric distribution. – Jack D'Aurizio Sep 25 '15 at 12:20
• No, it is a probability mass function, and the support is on $\{2;\infty\}$; however it is indeed a shifted geometric distribution. – Graham Kemp Sep 25 '15 at 12:33
• What is $\{2;\infty\}$? The support is $\{2,3,4,\ldots\}=\{n\in\mathbb N\mid n\geqslant2\}$. – Did Sep 25 '15 at 12:34
• Yes, that is what it is. The integer interval from $2$ towards infinity. – Graham Kemp Sep 25 '15 at 12:47

Quite simply you cannot have two consecutive head-or-tails until you have at least the second flip.   If $X$ is the count of flips required, then: $\mathsf P(X{=}1)=0,\, \mathsf P(X{=}2)=\tfrac 1 2, \,\ldots,\, \mathsf P(X{=}k) = \frac 1{2^{k-1}} \;\mathbf 1_{k\in\{2;\infty\}}$
That is, to have a consecutive head-or-tail on flip $k$, you need the first flip (what ever it is), the next $k-2$ flips to all be different to each of their predecessors, and last flip to be identical to its predecessor.
This means: $(X-1)\sim \mathcal{Geo_1}(\frac 1 2)$, that is $X$ has a shifted geometric distribution.
Let $Y\sim\mathcal{Geo_1}(\frac 1 2)$, then $X=Y+1$ and $\mathsf E(X)=1+\mathsf E(Y)=1+2=3$