Tossing coin until we obtain a tail that immediately preceded by a head

expected valueprobabilityrandom variables

I was reading Introduction to Probability, 2nd Edition, and the following question appears as exercise $23 (b)$ in the 2nd chapter:

A fair coin is tossed repeatedly and independently until we obtain a tail that is immediately preceded by a head.

Find the PMF and the expected value of the number of tosses.

My question is: if we let $X$ be the random variable that represents the number of tosses until we obtain a tail that is immediately preceded by a head, can we decompose it into two random variables:

$$X = Y + Z$$

such that $Y$ is the number of tossed until a head appears, and $Z$ is the number of tosses until a tail appears (starting from the moment after the head appears).

The calculation of expectations shows that $E[X] = E[Y] + E[Z]$ but is that just a coincidence or what? and If is true can we assume that $Y, Z$ are independent and thus calculating the variance with ease?

Also, are there conditions for such decomposition so one can prove or disprove his solution?

Best Answer

such that Y is the number of tossed until a head appears, and Z is the number of tosses until a tail appears (starting from the moment after the head appears).

  • None of the tails before the first head can follow a head.
  • All of the results between that first head and the next tail will be heads.
  • Therefore that tail will be the first tail to follow a head; and it shall be immediately.
  • Thus $Y + Z$ is the count of tosses until the first tail to immediately follow a head.

Use the Linearity of Expectation and the Law of Total Probability:

$$\mathsf E(X)=\mathsf E(Y)+\mathsf E(Z)$$

$$\mathsf P(X=k)=\sum_{j=1}^{k-1} \mathsf P(Y=j, Y+Z=k)$$

Additionally, since the toss of each coin is independent, the variables $Y$ and $Z$ are likewise independent as they represent counts for disjoint sequences of tosses (ie: the count for $Z$ proceeds only after the count for $Y$ terminates.) So indeed:

$$\mathsf{Var}(X) = \mathsf {Var}(Y)+\mathsf {Var}(Z)$$


As you have noted: Both $Y$ and $Z$ follow a $\mathcal{Geo}_1(1/2)$ distribution.