Thought Toys · Chance & inference · Exhibit 119

A bet worth infinity that nobody will pay $20 for

A casino flips a fair coin until it comes up heads. If that happens on the first flip it pays you $2; on the second, $4; on the third, $8, and so on, doubling. What is a ticket worth? Add it up and the answer is a half times two, plus a quarter times four, plus an eighth times eight — one, plus one, plus one, forever. The fair price is infinite. Nobody will pay twenty dollars for it, and nobody is being irrational.

What you have won per game, as the games pile up ● your running average   ● what the house can pay

games played average won what it's worth your profit

your turn — drag How much the house is able to pay all the way to a billion. The ticket gains ten dollars.

What you're seeing

Press Play. Each game is a coin flipped until it lands heads, paying two dollars doubled once for every tail that came first. The amber line is the average you have won so far, and the horizontal scale doubles at every step, so a million games fits beside ten.

The line does not settle. It steps up, roughly by a constant amount, every time the number of games doubles — which is what it means for an average to grow like a logarithm. Run it for a million games and a typical run leaves you near twenty dollars a game. Run it for a million million and a typical run would be near forty. Typical, not expected — one enormous win can put any particular run far above the line, and that is exactly why the expected value is infinite while the thing on screen is merely large. There is no number it is heading for. That is the whole of the paradox: the average of this game has no limit, so no price is too high.

Now look at the strip underneath, which shows the last sixty games. Almost every bar is at the floor. Exactly half of all games pay two dollars; three quarters pay two or four. The enormous average is not describing any game you are likely to play. It is being carried entirely by the tall spikes, and each spike is twice as rare and twice as large as the last, so their contributions never shrink.

Then find the resolution, which is the first slider. A real casino cannot pay an unbounded prize; it has a bankroll. Cap what the house can pay at two to the L, and the fair price of the ticket is not merely finite — it is exactly L + 1 dollars. A house good for a million pays $21 a ticket. A house good for a billion — a thousand times richer — pays $31. Ten more dollars for a thousandfold more money.

Read that number carefully, though, because “worth $21” is an average and not a promise. The capped game has a perfectly good expected value and a colossal variance: a player buying tickets at exactly the fair price loses money steadily for a very long time and is bailed out by one rare enormous win. The proof behind this page had to widen its own test band to allow for that — two million plays of the capped game still land several dollars away from the closed form. A price can be exactly right and still be a bad thing to pay this week.

So the infinity was never in the coin. It was in the tail of the sum, made entirely of payouts no counterparty on earth could honour. Cross that out and the paradox goes with it, leaving a number about the size of what people actually offer. Press Make the house infinitely rich to put the infinity back and watch the fair price stop being a number while the typical game does not change at all.

One more thing worth doing. Set your ticket price above the line and run it: you lose steadily, then a spike arrives and hands it all back, then you lose steadily again. A game with an unbounded mean does not make you rich. It makes your fortune a staircase you cannot plan around.

The rule, exactly. A fair coin is flipped until the first heads. If that is flip k, the payout is 2k, capped at the house's bankroll.

E[payout] = Σk≥1 2k · 2k = 1 + 1 + 1 + … capped at 2L:   E[payout] = L + 1

Every term of the uncapped sum is exactly one. Each doubling of the prize is cancelled precisely by the halving of its chance, so the series has no tail small enough to ignore and no last term. Nicolaus Bernoulli posed the problem in 1713; his cousin Daniel published the best-known answer in the St Petersburg Academy's proceedings in 1738, which is how a problem from Basel got a Russian name.

The coin is flipped at most 1000 times — a run that long has probability about 10−301, and 21000 is the largest payout that is still a real number in a browser — so what you are watching is technically a capped game with a cap nobody will ever reach. The page never claims to have measured an infinite average; it only ever shows you one that is still going up.

Verified in node before this page existed (improve/verify/119-st-petersburg.js, 28 checks):

  • Every term of the expectation is exactly 1, and the chance of winning at least 2k is exactly 2−(k−1).
  • Capped at 2L, the fair price is exactly L + 1 for every cap from 1 to 40, to the last digit a double can hold.
  • The running average over a million plays goes 7.1, 12.1, 15.7, 23.5 as the count passes 28, 212, 216, 220. It rises at every decade and is of the order of log2n throughout.
  • The control that makes that a result rather than a bug: the same coin, the same running-average code, but paying k dollars instead of 2k settles on 2.00 and stops moving. The divergence belongs to the payoff, not to the harness.
  • A second control: the capped game also settles — slowly, because its variance is enormous — and ten independent runs average to its closed form. Only the ceiling differs between the two.
  • A third: the off-by-one closed form L + 2, which a hurried derivation produces by forgetting that the whole tail pays the cap, is rejected by exhaustive enumeration.
  • A vacuity guard on the coin itself: over 400,000 games the observed distribution of first-heads flips matches 2k to 3.5%, and the longest run seen was 19 tails. A stuck coin would have satisfied "half the games pay two" while quietly emptying the exhibit.
  • The gate also corrected the page. The first draft said "the median payout is two", the textbook line. It is not safe: the distribution puts exactly half its mass on the single value 2, so the median sits precisely on a tie and a sample median comes back 2 or 4 at random. The page now says the thing that is true either way — half of all games pay exactly two.

Also in Chance & inference: Buffon's needle →

All 27 in Chance & inference
  1. 05The Galton board
  2. 06The Monty Hall problem
  3. 09Bayes' theorem
  4. 104You always land in the long gap.
  5. 110Five serial numbers. Now guess how many they built.
  6. 113In enough dimensions, nothing is near anything
  7. 115Play the best machine and you never find the best machine
  8. 119A bet worth infinity that nobody will pay $20 for — you are here
  9. 13Buffon's needle
  10. 14The central limit theorem
  11. 28Simpson's paradox
  12. 30Markov chains
  13. 31Averages that never settle
  14. 35The birthday paradox
  15. 38The drunkard's walk
  16. 39Zipf's law
  17. 40Benford's law
  18. 42The coupon collector's problem
  19. 48The wisdom of crowds
  20. 52Genetic drift
  21. 63The gaps are chaos. The count is law.
  22. 76Every bet here has an edge. Some sizes still go broke.
  23. 86Nobody got worse. The luck just didn't show up twice.
  24. 87Your friends really do have more friends than you.
  25. 96Plan for the average and you'll be wrong every time
  26. 98The numbers agree. The pictures don't.
  27. 99Unrelated in the crowd. A trade-off inside the gate.

← the cabinet