A machine spins a number from 1 to 10. You pay a price to play and name a number from 1 to 10. If the machine spins you win dollars, and otherwise you win nothing. What is the fair price to play?
The film says the machine spins "at random", and it does not say "equally likely". Somebody built the machine, and somebody set its odds. That matters, and it is where the puzzle is.
Write for the chance that the machine spins , with , and for the chance that you name , if you choose by chance. Your expected winnings, in dollars, are
You want this high and the builder wants it low. That is a game between two people, and its fair price is the amount neither can push their way: the best you can guarantee against the worst odds the builder could pick.
If every number is equally likely, the machine spins each with chance , and the mistakes are easy to make:
So on an equal machine the fair price would be a dollar, with a player who names 10 every time. But the builder can see that coming.
If you always name 10, the builder turns the dial for 10 down to nothing, and you win nothing. If you then name 9, the builder turns 9 down. Any number you name every time is a number the builder can starve. So you have to name numbers by chance, and the builder has to set odds knowing you will.
Give the number a weight in proportion to . The weights must add up to one, so divide by :
To avoid fractions, use the common denominator 2520, which is the smallest number that all of 1 to 10 divide. The tickets are then , and the total is 7381, so .
Now whatever odds the builder sets, your expected winnings are
This is because for every : the weight of a number is exactly cancelled by its prize. The script checks that is 2520 for each , and the sum of the is 1 by definition. So you collect ≈ 0.3414 dollars on average, whatever the builder does. That is 34 cents, and it is the most you can be sure of.
Now the builder's side. Let the machine spin with chance , the same weights. If you name and stay with it, your expected winnings are , the same for every . Every number is worth the same to you, so whatever you do, you get on average, and no better. This is the builder's guarantee.
Here are the odds, with the number of tickets out of 7381 that the film uses:
| number | tickets | chance | worth if named once |
|---|---|---|---|
| 1 | 2520 | 34.1% | 0.3414 |
| 2 | 1260 | 17.1% | 0.3414 |
| 3 | 840 | 11.4% | 0.3414 |
| 4 | 630 | 8.5% | 0.3414 |
| 5 | 504 | 6.8% | 0.3414 |
| 6 | 420 | 5.7% | 0.3414 |
| 7 | 360 | 4.9% | 0.3414 |
| 8 | 315 | 4.3% | 0.3414 |
| 9 | 280 | 3.8% | 0.3414 |
| 10 | 252 | 3.4% | 0.3414 |
The last column is the same for every row, and it is the fair price in dollars.
The two routes meet. You can guarantee whatever the builder does, and the builder can hold you to whatever you do. So the value of the game is exactly .
You can also see directly that no mix does better for you. Suppose a mix gave you at least dollars against every number the builder could favour, which means for every . Then , and adding over all ten numbers,
The script also tries 400,000 spins with a seeded generator, and 50,000 random mixes of the weights: the best any of them could guarantee was 0.2197, below 0.3414.
Here is what the machines do over 400,000 spins in the script, in dollars per spin. These are simulated and approximate.
| player | machine | average winnings |
|---|---|---|
| names 10 every time | equal odds | 0.9991 |
| names a number at random | equal odds | 0.5504 |
| mix with weights | equal odds | 0.3485 |
| names 10 every time | odds | 0.3394 |
| mix with weights | odds | 0.3426 |
Against equal odds, the person who names 10 every time does best. Against the builder's odds, naming 10 earns the fair value like everything else. If you charged 34 cents against an equal machine, a player who named 10 every time would win about 66 cents a spin from you: that is the cost of setting the price without thinking about the player.
Another top number. With numbers from 1 to the fair price is . It falls slowly as grows, because grows like . For the price is 1 dollar, for it is , and for the film's 10 it is 0.3414.
Other prizes. If the prize for is , the same argument says to weight by , and the fair price is . Here .
scripts/number-machine.mjs asserts the claims below before it writes maths.json, and its --check fails if the file is stale. It checks that:
The proof that no mix does better is the sum above, not the simulation, and it holds for any .
, so the fair price is dollars.
The prize on 10 is ten times bigger, so a number that is ten times more likely to be named would be ten times more expensive for the builder. To make every number worth the same, the weights go the other way, so 10 gets a tenth of the weight of 1: 252 tickets against 2520.
Ten, every time. Against equal odds that earns 1 dollar per spin, which is more than the fair price. The fair price is the answer to a builder who is also thinking, not to a careless one.