Daniel Litt on Twitter suggests a puzzle with a surprising
answer:
Flip a fair coin 100 times—it gives a sequence of heads (H) and tails
(T). For each HH in the sequence of flips, Alice gets a point; for each
HT, Bob does, so e.g. for the sequence THHHT Alice gets 2 points and Bob
gets 1 point. Who is most likely to win?
Like many others, I intuitively assumed the answer would be Alice,
since her winning segments can overlap, while Bob’s can’t. And yet the
right answer is Bob:
The correct answer is “Bob.” Congrats to the 10% who got it right —
those few brave dreamers.
To figure out the answer, let’s represent the game as the following
Markov chain:
Markov chain transition
diagram
We start at \(S_1\), and every time
a coin is flipped, we move to another state according to the diagram.
When we reach state \(S_3,\) Alice gets
a point, and when we reach \(S_4,\) Bob
gets a point.
While raising this matrix to the \(n\)th power would allow us to compute the
probabilities of ending up in different states after \(n\) steps, this is not enough to keep track
of Alice’s and Bob’s scores. For that, let’s multiply the transition
probabilities by \(x\) if Alice gets a
point after a transition to that state and by \(x^{-1}\) if Bob does. Our matrix is
then
Transition probabilities computed using such a matrix are Laurent
polynomials in \(x\), \(\sum a_k x^k\), where \(a_k\) is the probability of arriving at the
given state and having Alice earn \(k\)
more points than Bob. So to answer the original question, we need to see
whether the sum of the coefficients of \(x^k\) for \(k>0\) is more, less, or equal to the sum
of the coefficients of \(x^k\) for
negative \(k\) after 100 steps. Since
we start at \(S_1\) and can finish in
any state, the polynomial of interest is the sum of the first row of
\(A^{100}\).
Tallying up the coefficients, Alice wins with probability \(580127949239420834381088427404/2^{100} ≈
0.4576\), Bob wins with probability \(615866238418960422359689555420/2^{100} ≈
0.4858\), and there is a tie with probability \(71656412569848144755925222552/2^{100} ≈
0.0565\).
Here are the outcome probabilities for different numbers of tosses
(cf. the simulation results here).
Outcome probabilities for different
numbers of total coin tosses
The Haskell code for computing the probabilities is available here.