Yashmeen Halfcourt is a mathematician and one of the major characters in Pynchon’s book “Against the Day”. And she seems to have figured out a way to beat the odds in roulette using prime numbers?
But then wheels all up and down the Riviera, at Nice, Cimiez, Monte Carlo, Mentone, through the winter season and into the spring, like village gossips, had begun to chatter a different story. Pockets began to go out at the seams from all the winnings being stuffed into them.
The system had its origins in a ride she’d taken with Lorelei, Noellyn, and Faun on the Earl’s Court Wheel, centuries ago in her girlhood. “Thirty-seven numbers on the wheel,” she instructed him. “The zero belongs to the house. Of the other thirty-six, twelve—if you include one and two—are primes. Going clockwise, taking three numbers at a time, in each set of three you will find exactly one prime.”
“So they’re spread out pretty even.”
“But the wheel makes more than one revolution. The numbers repeat again and again, like a very fast clock with thirty-seven hours. We say thirty-seven is the ‘modulus’ of the wheel, as twelve is the modulus of an ordinary clock. So the number that a roulette ball comes to rest at is actually that number ‘modulo thirty-seven’—the remainder, after dividing by thirty-seven, of the total of moving compartments the ball has had a chance to fall into.
“Now, by Wilson’s theorem, the product (p — 1) factorial, when taken modulo any prime p, is always equal to minus one. On the roulette wheel, p — 1 is thirty-six, and thirty-six factorial also happens to be the number of all possible permutations of thirty-six numbers. It is thus obvious from the foregoing that—”
She was interrupted by the thud of Reef’s head on the table, where it remained. “I don’t think he’s been following this,” she muttered. But continued to whisper the lesson to him, as if choosing to believe he had only fallen into a light hypnosis. Apparently it worked, because in the coming days he began to win at roulette far outside the expectations of chance.Pynchon, Thomas. Against the Day (S.862-863). Penguin Publishing Group. Kindle-Version.
“It is thus obvious from the foregoing that..” is a phrase professors love to use for handwaving away tedious explanations that are often not quite as clear for the students listening to their lecture. But in this case, the conclusion is more than not obvious: It’s obviously bullshit. Of course, we don’t know what Yashmeen told Reef after he fell asleep, but I would be very impressed if it would involve using Wilson’s theorem in some clever way. So why does Pynchon bring it up at all? Maybe he intended it just as some technobabble that readers are expected to skip over. This would play nicely along with the interpretation of “Against the Day” as a science fiction story as written by people living in 1900. But I think there might be something more going on: Wilson is also the name of an author who wrote a book titled “The Casino Gambler’s Guide”. In this book, Wilson describes how one could make a profit from gambling: Some roulette tables might be biased, meaning the ball is more likely to fall in a particular section of the table. If this bias is big enough, there is an easy winning strategy: Just always bet on the number with the highest winning probability.
But there are two things you have to figure out first:
1.) How much money to bet
Even if you find a roulette table heavily biased toward a certain number, you need to be smart in how much money you bet on it:
- If you go “all in” you are at great risk to just go broke immediately.
- If you only ever place tiny bets, getting rich will take you forever, and the casino authorities might get wind of your shenanigans and escort you out.
Luckily there is a betting strategy that’s proved to be optimal in this case: Using the Kelly criterion, you can calculate the percentage of your bankroll that should be bet. It’s quite straightforward:
Let’s say that you know that there is a 5% per cent chance for a certain number and betting an amount x on it will net you a 35x return. So you should bet:
(5%*x*35 – 95%*x)/35x = ~2,3% of your total money.
Note that it’s very hard to go broke with this approach because the size of your bet grows and shrinks proportionally with your current bankroll.
It’s also recommended to not only bet on a single number but to use the above formula for all of them and place a bet for each. This will hedge against bad luck but could also be perceived as suspicious behaviour.
2.) How to figure out if a certain roulette table is biased in the first place
After observing the roulette results for some time, how do you determine if the table is biased or if the deviations from a uniform distribution are just due to random chance?
To get a perfect estimate of the involved probabilities, you would need to watch the roulette table for an infinite amount of time. But luckily you can start betting way earlier than that. By using the Dirichlet distribution, you can calculate how likely the roulette table is biased. Its density function gives the probabilities of K different, exclusive events if each event was observed _i times. For roulette, the K different events are the ball landing in a particular pocket.
Calculating the Dirichlet distribution is pretty complicated. Among other things, it requires determining the gamma function (p-1)!. Coincidentally this is also needed for applying Wilson’s theorem. So maybe Yashmeen’s talk about it was just a very roundabout way to get started on the Dirichlet Distribution?
Let’s look at a little example:
You observe the roulette wheel for 10 games: 1 time the ball lands in pocket number 7, the other 9 times it lands in different pockets. How big is the chance that the probability for number 7 is bigger than 1/36?
We don’t need to those calculations ourselves, but can just ask Wolfram Alpha:
A 75% chance sounds pretty good. But before jumping in on a big bet, consider that we only observed 10 games. Yes, that means that the certainty of the certainty of the certainty of where the ball falls is low (I’m not stuttering). To avoid falling prey to this, it is suggested to go in with a healthy prior: The assumption that all numbers are equally likely. This can be done by setting all of the _i values to an equal and pretty big value. So in a way, we pretend that we have already seen a lot of games where every outcome was observed the same number of times.
But what’s a good starting point for setting the values? A guy named Jerome Klotz run a bunch of simulations he describes in this paper (he also provides a mathematically rigorous description of the optimal roulette strategy). He finds out that setting the values somewhere between 200 and 500 gets good results when the bias of one of the numbers is 1/30 instead of the expected 1/36. But you would need to play a lot: After 5000 games with alphas of 500, your expected winnings are only a little bit more than 5%. And there is still a significant risk of losing money instead. So Yashmeen and Reef might have just been lucky.
If you are interested in this sort of stuff and want to read more about it, I can recommend the book “Fortune’s Formula: The Untold Story of the Scientific Betting System That Beat the Casinos and Wall Street”. Among other things, it talks about the attempts of Claude Shannon to beat the house in roulette using a hidden camera. Claude Shannon is known as the “father of information theory” and introduced the concept of “information entropy”. This concept plays quite an essential part in Pynchon’s work, so I can’t wait to write a blog post about it. See you then!