How a magician-mathematician exposed a loophole in the casino
To study rifle shuffles thoroughly, Diaconis used a powerful mathematical tool called a Markov chain.
“A Markov chain is any repeated action in which the outcome depends only on the current state and not on how that state was reached,” explains Sami Hayes Assaf, a mathematician at the University of Southern California. This means that Markov chains have no “memory” of what came before. This is a pretty good model for shuffling cards, says Assaf. The result of the seventh shuffle depends only on the order of the cards after the sixth shuffle, not on how the deck was shuffled the five times before that.
Markov chains are widely used in statistics and computer science to deal with sequences of random events, whether they are shuffling cards or vibrating atoms or fluctuations in stock prices. In each case, the future “state”—the order of the tire, the energy of an atom, the value of a stock—depends only on what happens now, not what happened before.
Despite its simplicity, Markov chains can be used to make predictions about the probability of certain events after many iterations. Google’s PageRank algorithm, which ranks websites in search engine results, is based on a Markov chain that models the behavior of billions of internet users who randomly click on web links.
Working with Dave Bayer, a mathematician at Columbia University in New York, Diaconis showed that the Markov chain describing rifle shuffles has a sharp transition from ordered to random after seven shuffles. This behavior, known to mathematicians as a cutoff phenomenon, is a common feature of problems involving mixing. Think of stirring cream into coffee: As you stir, the cream forms thin white streaks in the black coffee before suddenly, and irreversibly, mixing.
Knowing which side of the cutoff a deck is on—whether it’s properly shuffled or still has some memory of its original order—gives players a distinct advantage against the house.
In the 1990s, a group of students at Harvard and MIT were able to beat the odds playing blackjack in casinos around the United States by using card counting and other methods to detect whether the deck was properly shuffled. Casinos responded by introducing more sophisticated shuffling machines, shuffling the deck before it is finished playing, as well as increased monitoring of players. But it’s still rare to see a deck shuffled off the machine the required seven times in a casino.
Casino executives may not have paid much attention to Diaconis and his research, but he continues to have an enormous influence on mathematicians, statisticians and computer scientists who study randomness. At a conference held at Stanford in January 2020 to honor Diaconi’s 75th birthday, colleagues from around the world lectured on the mathematics of genetic classification, how cereal stacks in a shaker box, and, of course, shuffling.
Diaconis doesn’t care much about gambling himself – he says there are better and more interesting ways to make a living. But he doesn’t begrudge players who try to gain an advantage by using their brains.
“Thinking is not cheating,” he says. “Thinking is thinking.”
*Shane Keating is a science writer and pSenior Lecturer in Mathematics and Oceanography at the University of New South Wales, Sydney
Join a million Future fans by continuing to like us Facebookor follow us further Twitter or Instagram.
If you enjoyed this story, sign up for the weekly bbc.com features newslettercalled “The Essential List” – a handpicked selection of stories from the BBC Future, Culture, Working life, Travel and Coil delivered to your inbox every Friday.