Chapter 10
Should You Pay $250 To Play This Casino Game?
Suppose a casino invents a new game that you must pay $250 to play. The game works like this: The casino draws random numbers between 0 and 1, from a uniform distribution. It adds them together until their sum is greater than 1, at which time it stops drawing new numbers. You get a payout of $100 each time a new number is drawn.
For example, suppose the casino draws 0.4 and then 0.7. Since the sum is greater than 1, it will stop after these two draws, and you receive $200. If instead it draws 0.2, 0.3, 0.3, and then 0.6, it will stop after the fourth draw and you will receive $400. Given the $250 entrance fee, should you play the game?
Specifically, what is the expected value of your winnings?
The Riddler, FiveThirtyEight(original post)
Solution
Let be the number of draws the casino makes, so the payout is and we need . Write for the sum of the first uniform draws. The game is still running after draws exactly when , that is, when .
The chance that independent uniform values sum to at most is the volume of the simplex , which is the clean (Each ordering of the values is equally likely and fills one of the congruent pieces of the unit cube, and exactly one ordering keeps the running sum inside the simplex.) Summing the tail probabilities, So on average the casino makes draws and your expected payout is That clears the $250 fee by about $21.83 in expectation, so the game is worth playing.
The computation
Play the game itself: draw uniform values until the running sum first exceeds , count the draws, multiply by $100, and average over many plays. The mean lands on .
import numpy as np
rng = np.random.default_rng(0)
runs = 2_000_000
total_payout = 0
for _ in range(runs):
s = 0.0; draws = 0
while s <= 1: # keep drawing until the sum exceeds 1
s += rng.random(); draws += 1
total_payout += 100 * draws
print(total_payout / runs) # ~271.83 = 100 * e