[Math] Probability of two consecutive head or tail or any one of them in a row

combinatoricsprobability

Fair coins are tossed and when either four consecutive heads and tails appear the process will be stopped. What is the probability of two consecutive head or tail or any one of them in a row?

Best Answer

Because heads and tails play symmetric roles in the stopping criterion (and presumably have equal chances in each Bernoulli trial), it suffices to find the probability of getting two consecutive heads before the process stops.

If the process stops with four consecutive heads, obviously that means also we got two consecutive heads before the process stops. So we can focus on the probability $p$ that we get two consecutive heads before the process stops with four consecutive tails.

One way to compute this is by defining a Markov chain with two absorbing states, a) two consecutive heads and b) four consecutive tails. Finding $p$ amounts to finding the probability of reaching the first of these absorbing states (two consecutive heads).

The Wikipedia write-up of absorbing Markov chains may be overly concise, so here are some details. Ordering the transient states before the absorbing states gives a probability transition matrix having block structure:

$$ P = \begin{bmatrix} Q & R \\ 0 & I \end{bmatrix}$$

so that $Q$ gives the transition probabilities between the transient states and $R$ the transition probabilities from transient to absorbing states.

We define the fundamental matrix $N = \sum_{k=0}^\infty Q^k = (I-Q)^{-1}$, and the product $NR$ then gives the probabilities of eventually reaching an absorbing state starting from a transient state.

In the case at hand it is convenient to use four transient states (consecutive runs of one Head or of one to three Tails, resp.) and two absorbing states (two consecutive Heads or four consecutive Tails). Taking the states in just this order gives:

$$ P = \begin{bmatrix} 0 & \frac{1}{2} & 0 & 0 & \frac{1}{2} & 0 \\ \frac{1}{2} & 0 & \frac{1}{2} & 0 & 0 & 0 \\ \frac{1}{2} & 0 & 0 & \frac{1}{2} & 0 & 0 \\ \frac{1}{2} & 0 & 0 & 0 & 0 & \frac{1}{2} \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} $$

$$ N = (I-Q)^{-1} = \begin{bmatrix} \frac{16}{9} & \frac{8}{9} & \frac{4}{9} & \frac{2}{9} \\ \frac{14}{9} & \frac{16}{9} & \frac{8}{9} & \frac{4}{9} \\ \frac{4}{3} & \frac{2}{3} & \frac{4}{3} & \frac{2}{3} \\ \frac{8}{9} & \frac{4}{9} & \frac{2}{9} & \frac{10}{9} \end{bmatrix} $$

$$ NR = \begin{bmatrix} \frac{8}{9} & \frac{1}{9} \\ \frac{7}{9} & \frac{2}{9} \\ \frac{2}{3} & \frac{1}{3} \\ \frac{4}{9} & \frac{5}{9} \end{bmatrix} $$

For economy I omitted an "empty" state, so we imagine our Markov process to initialize in state one Head with probability $1/2$ and likewise in state one Tail with probability $1/2$. From the above computation it follows that our chance of reaching two consecutive Heads before four consecutive Tails is:

$$ (1/2)\frac{8}{9} + (1/2)\frac{7}{9} = \frac{5}{6} $$

This is the same as our chance of reaching two consecutive Tails before four consecutive Heads.