Unexpected coin flip experiment

In this post, I explore a seemingly straightforward coin flip game between two players. Interestingly, the intuitive approach fails when validated with a Monte Carlo simulation.


Interesting idea from this X post by @littmath:

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?

If we pause to analyze, it might initially seem that Alice has the upper hand. Consider a perfect scenario: if the sequence were all heads (HHHHHHHHHH), Alice could rack up to 9 points out of 10 flips. On the flip side (pun intended), in a mixed sequence like HTHTHTHTHT, Bob would only manage to score 5 points out of 10. This reasoning suggests Alice might have a better chance of winning, right?

But the Monte Carlo simulation says otherwise. With N=1M iterations, Bob comes out ahead:

import numpy as np

np.random.seed(0x1B)
N = 1_000_000
bob_wins = 0
alice_wins = 0

for i in range(N):
    flips = np.random.randint(0, 2, size=100)  # 0: head, 1: tail
    flips_diff = np.diff(flips)  # 1 for TH, -1 for HT, 0 otherwise
    points_alice = np.sum((flips_diff == 0) & (flips[:-1] == 0))  # HH
    points_bob = np.sum(flips_diff == -1)  # HT
    if points_bob > points_alice:
        bob_wins += 1
    elif points_bob < points_alice:
        alice_wins += 1
Probability of winning the coin-pair flip game for Bob and Alice (N = 1,000,000 simulations).

The catch is that Alice might score more points in a single game, but Bob wins more games. Let’s enumerate all possible outcomes with just 4 coin flips to understand why:

FlipsPoints AlicePoints BobWinner
TTTT00Draw
TTTH00Draw
TTHT01Bob
TTHH10Alice
THTT01Bob
THTH01Bob
THHT11Draw
THHH20Alice
HTTT01Bob
HTTH01Bob
HTHT02Bob
HTHH11Draw
HHTT11Draw
HHTH11Draw
HHHT21Alice
HHHH30Alice

The breakdown shows Bob’s advantage: he wins more often than Alice in this simplified scenario. The total points across all games are equal (12 each), yet Bob wins more often by a small margin. Worth keeping in mind the next time a probability problem looks obvious.