Skip to content
All apps

Penney’s game 2.0

About this app

Rebuild 2.0 (preview): exact odds via Conway, non-transitivity as a graph on waiting-time rings, waiting-time paradox, matrix of all duels, Monte Carlo, length 3 and 4.

Conway’s formula for coin sequences

In Penney’s Game a fair coin is tossed until A’s or B’s sequence appears as a block. John Conway found an exact rule for the winning odds. For two sequences X and Y, form the overlap number XY: for every k where the last k flips of X match the first k flips of Y, add 2^(k−1). The odds are then P(B wins) : P(A wins) = (AA − AB) : (BB − BA). The same numbers give the average waiting time of a single sequence: E[T] = 2·XX flips.

What the app shows

In the duel panel you set A’s and B’s sequences, with 3 or 4 flips. The app shows the exact winning chance, the odds, the average game length and the calculation with Conway’s overlap numbers. A graph places all sequences on rings by waiting time; arrows point from the best reply to the sequence it beats and reveal the cycle. Further panels show the waiting time distribution from a Markov chain, a matrix of all matchups and a Monte Carlo simulation with a 95 % funnel.

Try the waiting time paradox

Set A to H-T-H and B to H-T-T. Tossed on its own, H-T-T appears after 8 flips on average and H-T-H only after 10, because H-T-H overlaps with itself and its hits come in clusters. Head to head, the duel is still exactly 50 : 50. Then switch to length 4: there are matchups in which the sequence that is slower on average wins. Tap cells in the matrix to load a matchup.

Frequently asked questions

How do you calculate the winning probability in Penney’s Game?
With Conway’s algorithm: for each pair of sequences you compute overlap numbers by checking where the end of one sequence matches the start of the other. Each match of length k counts 2^(k−1). The odds for B are then (AA − AB) : (BB − BA).
Why do some coin sequences take longer to appear?
Sequences that overlap with themselves, such as H-T-H or H-H-H, show up in clusters with longer gaps in between. They are just as frequent, but their average waiting time is longer. The formula E[T] = 2·XX gives 8 flips for H-T-T, 10 for H-T-H and 14 for H-H-H.
Does the sequence with the shorter waiting time always win?
No. The average waiting time alone does not decide which sequence comes first. H-T-T and H-T-H have different waiting times yet split their duel 50 : 50. With length-4 sequences there are even matchups in which the slower sequence wins.
What does this version add to the first Penney app?
It computes every value exactly with Conway’s method and a Markov chain instead of only simulating. It adds length-4 sequences, the waiting-time ring graph, a matrix of all matchups and a Monte Carlo simulation compared against the exact value.

Subject: Data & decisions

More from Data & decisions

A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps