Quantcast
issue
Read articles, including Science News stories written for ages 9-14, on the SNK website.
Shuffling the cards: Math does the trick
When to stop shuffling depends on the game
A+ A- Text Size

When to stop shuffling depends on the game

By Julie Rehmeyer

Web edition: November 7, 2008

Enlarge
PRISONERS' CODE
ENLARGE | Stanford University researchers used mathematics to break coded messages prisoners were sending to each other. To find out what this note says, read the team's paper.

Here’s the rule: To assure cards get sufficiently mixed up, shuffle a deck about seven times. Mathematician, magician and card shark Persi Diaconis of Stanford University, along with David Bayer of Columbia University, created shock waves in Las Vegas when he figured that out back in 1992. Most dealers had been shuffling much less.

But now Diaconis and his colleagues are issuing an update. When dealing many gambling games, like blackjack, about four shuffles are enough. The reason for the lower number is that many games require randomness for only a few specific aspects of the cards, not all. In blackjack, for example, suits don’t matter. Diaconis and his collaborators extended the earlier analysis to account for these variations.

Gamblers and casinos aren’t the only ones who will benefit. One the most useful tools for applied mathematicians — the Monte Carlo simulation — was inspired by the games of chance that are main attractions in Monte Carlo, Monaco. The new card-shuffling results apply directly to this method, promising to save mathematicians computer time.

Shuffling starts by cutting the deck roughly in half. During the shuffling, a few cards fall from one side, then a few from the other. Diaconis, Sami Assaf of the Massachusetts Institute of Technology and K. Soundararajan of Stanford University made the same assumption Diaconis and his collaborator Dave Bayer made back in 1992, that the cards are more likely to fall from the larger stack — an assumption borne out in real life.

Assaf started by using a very small deck, just four cards, and played with it a lot. Then she tried five, then six. From her experiments, she guessed a formula for how mixed the cards were, for whatever property she cared about. Then she worked out a proof.

The formulas she generated, though, were a mess. “We couldn’t actually calculate them,” she says. “We would have had to run the computer for 64 years or something like that.”

So she took each messy, complicated formula to Diaconis and Soundarajan, and for each they found a simple, easy-to-compute equation that approximated it. “We found a beautiful simple pattern,” Diaconis says. “There’s no reason this problem should have a nice answer. I’m not a religious person, but this is as close as I get.”

Previous researchers, specifically Mark Conger and Divakar Viswanath of the University of Michigan, had used computer simulations to work out some of these results. What makes the new approach from Diaconis and his colleagues stand out is that it can be applied to many different card games, using any number of cards. Even better, it can be used for situations far removed from cards, like Markov Chain Monte Carlo simulations, a technique that has revolutionized applied mathematics over the past few decades.

Markov Chain Monte Carlo simulations harness the power of randomness to solve all kinds of problems that don’t seem random at all. For example, prison officials once asked other mathematicians at Stanford for help decoding a collection of messages. The mathematicians guessed it had been made with a simple substitution cipher, where each symbol corresponded to a letter of the alphabet. The easiest way to solve substitution ciphers is by associating the most frequently used symbol with the most frequently used letter in English (e), the next most frequently used symbol with the next most frequently used letter (t), an so on. But that method failed.

The mathematicians then moved to the next level of sophistication, looking at the frequency of pairs of letters. They downloaded a copy of War and Peace and used it to build a table, showing the frequency with which one letter follows another. This table had 26 columns and 26 rows, and 26 times 26 equals far too many for deciphering by hand.

So the mathematicians used a Markov Chain Monte Carlo simulation. They built a simple program that chose a random letter to associate with each symbol. It then decoded the message using that substitution cipher and calculated how probable it was that the resulting pairs of letters in the decoded message would follow one another. It repeated the process with another random substitution cipher. If the new one was more probable, it picked it. If not, it usually kept the original one, but occasionally switched to the new one. After a thousand or so iterations, it had decoded the message — even though the message was written in a mix of English, Spanish and prison jargon.

One of the tricks is recognizing when the simulation can stop, and Diaconis’ new result for shuffling can help with that. Choosing a new random solution in a Markov Chain Monte Carlo simulation is a bit like a shuffle of the cards. The methods Diaconis has developed to recognize when a dealer can safely stop shuffling the cards can also tell when the computer can stop running the simulation.

“We’re all enthusiastic,” Diaconis says, “because you can describe it to your mom, the math is hard, and the results are interesting.”

Comment
Print Friendly and PDF

Assaf, S., Diaconis, P. and Soundararajan, K. 2008. A rule of thumb for riffle shuffling. Available at [Go to]

Diaconis, P. 2008. The Markov Chain Monte Carlo Revolution. Available at [Go to]

Bayer, D. and Diaconis, P. 1992. Trailing the dovetail to its lair. Annals of Applied Probability 2 (No. 2): 294. [Go to].

Comments (19)

Please alert Science News to any inappropriate posts by clicking the REPORT SPAM link within the post. Comments will be reviewed before posting.

  • Interesting article, but the spelling leaves something to be desired.
    Shonn McNeill Shonn McNeill
    Nov. 8, 2008 at 5:26am
  • Please enlarge more precisely on what is meant by shuffling. Is it mixing the two 'halves' of the pack via riffling or is it by loosely mixing one 'half' with the other via shaking one 'half' on top of the other so that the cards intersperse unpredictably or is it some other system e.g. simply cutting the pack seven times? My interest is in shuffling for party bridge.
    Nicholas  De Morgan Nicholas De Morgan
    Nov. 9, 2008 at 11:56am
  • 'One thousand iterations' does not sound useful to me. Functionally, the prisoners code worked--it did it's job. There is no 'real time' analysis, and a series of messages will be possible. The only possible use for this would be retrospective application of punishment--it would not serve as a prevention.
    Phil Grimm Phil Grimm
    Nov. 10, 2008 at 7:58am
  • @phil: running 1000 iterations of a MCMC chain on modern hardware is trivial. this model could definitely be run in real-time. running a 100k chain with a much more complicated model on 5-6 yrs old hardware implemented in a scripting language takes about 15 minutes.
    anon mous anon mous
    Nov. 14, 2008 at 10:38am
  • Four shuffles is adequate? Maybe it is

    Do they take into consideration that most good experienced blackjack dealer's riffles are (virtually) perfect; that is to say that they intertwine the cards as single cards and not as random clumps of 1, 2, 3, or more cards?
    Flash1296 Flash1296
    Nov. 14, 2008 at 10:52am
  • They did or didn't develop a system that will decode messages in real-time? I mean what use is it, if it doesn't address the issue of whether the dealer is right-handed or left-handed? Oh, and what else does the article say, because I can't be bothered to download it and read it. I have the attention span of a gnat, and I think that my ADD makes me kewl... C'mon, guys!!! This is cool stuff. Customarily, one chooses some arbitrary number of iterations in an MCMC analysis, and these guys have come up with a systematic way to determine whether 100, 1,000, 10,000, or whatever is the optimal number of iterations. It is developments that add to the rigor and quality of statistical research. Julie, thank you for this post.
    Natasha Fatale Natasha Fatale
    Nov. 14, 2008 at 3:07pm
  • Nicholas De Morgan: cutting the pack N times is no different from cutting it once.
    Anton Sherwood Anton Sherwood
    Feb. 26, 2009 at 3:24pm
  • Gamblers and casinos aren’t the only ones who will benefit. One the most useful tools for applied mathematicians — the Monte Carlo simulation — was inspired by the games of chance that are main attractions in Monte Carlo, Monaco. The new card-shuffling results apply directly to this method, promising to save mathematicians computer time. [Link was removed]
    Marie Curie Viet Nam Marie Curie Viet Nam
    Nov. 24, 2009 at 9:54am
  • CHOP used to be an acronym for Cyclophosphamide, drugs starting in H and O and prednisone but they changed the two middle drugs and kept the acronym (and added -R for rituxan). I had this for diffuse large B-cell lymphoma (NHL) in summer-fall 2003, after losing 20 lb of mostly muscle (down to 93 lb). I gained back 30 during and after chemo. Before starting chemo I was too weak to sit up but got progressively stronger during chemo as I regained muscle, except for periods of weakness for a copule of days after the 5 days of prednisone, which prevents muscle growth. My partner dragged me out for walks starting about a week after my first therapy, at first a slow progression to the curb and back (the porch step was a problem), then we made it to the near corner, the far corner, the nearby orchard a few houses away where I sat as he picked windfalls, eventually around the block, to the pharmacy 1/4 mile away (a 'milestone') and after four months I made it to town 1 mile away, rested at the only placeopen Christmas day (Chinese restaurant) and back. That summer sohbet I went swimming and managed 1.5 lengths of the area (20 = mile) first time, 3 second. Next summer I went with another lymphoma survivor and gradually made it to a mile with rests. I still drag myself up stairs by the handrail and runout of breath, but am up to 15 pushups and 50 situps. Start with vertical pushups against the wall. Normal activities are not enough. I can run 1/2 of a short block, slowly. I am 55 now and bike everywhere. Hot flashes continue 2.5 years but every 3 hours not 45 min and shorter and milder. Still hurts where I sit. Doctor told me the foot cramps and frequent colds are due to chemo. Colds are caused by chemo wiping out the memory part of your B cells (immune response) and should be temporary, but they advised a flu shot. See my diary of 6 months chemo at (or similar - go to the main site). How long has it taken others to regain muscle strength after weight loss? , Good post,I think so!abercrombie and fitch on Sale, Hoodies, Jeans, T-Shirts, Pants, Polos hollister abercrombie outlethollister clothing Abercrombie Men Tee abercrombie womens polos Ruehl No.925, Men, women, and children's clothing. abercrombie and fitch , [Link was removed] ,abercrombie and fitch and abercrombie and fitchfashion is bold and interesting, all thanks to the interestingand original designs of Don
    [Link was removed]
    webalem net webalem net
    Dec. 18, 2009 at 3:53pm
  • Thanks for great news!
    [Link was removed]
    Ben Hurtisson Ben Hurtisson
    Dec. 25, 2009 at 11:27am
  • Genetic disorders are often caused by sperm DNA that has double strand breaks, copy number variations, point mutations and imprinting mutations that have to do with advancing paternal age. Men need to know about their biological clock and father babies in their 20s and very early



    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    iSo AsTaLaViSTa iSo AsTaLaViSTa
    Dec. 26, 2009 at 9:21pm
  • Great stuff!
    [Link was removed]
    Samuel Jaxon Samuel Jaxon
    Dec. 28, 2009 at 6:20am
  • Julie Rehmeyer, I want to place your article on their sites.
    I do this?
    My Sites: [Link was removed] , [Link was removed] , [Link was removed]
    kopilka Derty kopilka Derty
    Jan. 8, 2010 at 9:40am
  • film izle bedava

    [Link was removed]
    film izle bedava flim izle film izle bedava flim izle
    Jan. 9, 2010 at 5:27am
  • Was very useful article. Thank you.. [Link was removed]
    asda asdasd asda asdasd
    Jan. 10, 2010 at 7:32pm
  • CHOP used to be an acronym for Cyclophosphamide, drugs starting in H and O and prednisone but they changed the two middle drugs and kept the acronym (and added -R for rituxan). I had this for diffuse large B-cell lymphoma (NHL) in summer-fall 2003, after losing 20 lb of mostly muscle (down to 93 lb). I gained back 30 during and after chemo. Before starting chemo I was too weak to sit up but got progressively stronger during chemo as I regained muscle, except for periods of weakness for a copule of days after the 5 days of prednisone, which prevents muscle growth. My partner dragged me out
    [Link was removed] [Link was removed] [Link was removed] [Link was removed]
    [Link was removed] [Link was removed] [Link was removed] [Link was removed] [Link was removed] [Link was removed]
    [Link was removed] [Link was removed] [Link was removed] [Link was removed]
    [Link was removed]
    KruGer KruGer KruGer KruGer
    Jan. 12, 2010 at 4:54pm
  • hımm [Link was removed] Thank you very nice stories
    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed] [Link was removed]
    [Link was removed] [Link was removed]
    [Link was removed] [Link was removed]
    [Link was removed] [Link was removed]
    [Link was removed]
    [Link was removed]
    [Link was removed]
    Manga İndir Manga İndir
    Jan. 15, 2010 at 10:47am
  • mynet okey oyna
    mynet okey
    okey oyunu oyna
    okeyoyunuoyna
    okey indir
    okey indirme
    okey yükle
    okey oyunu
    okey oyun
    okey oyna
    okey
    okey oyna
    okey oyunları
    okey oyunu oyna
    okey oyunu
    bedava okey
    samsun
    malatya
    yalova
    chat
    sohbet
    okey oyunu oyna
    okey oyna
    okey
    bedava okey
    okey oyna
    okey
    okey oyunu oyna
    bedava okey
    canlı okey
    onine okey
    chat sohbet
    sohbet chat
    kameralı sohbet odaları
    sohbet
    kameralı sohbet
    sohbet odaları
    chat
    muhabbet odaları
    muhabbet odası
    muhabbet sohbet
    muhabbet chat
    muhabbet
    okey oyna okey oyna
    Feb. 3, 2010 at 6:09pm
  • did riffle shuffle on Matlab, sufficient amout for a random mix was 4 times



    Vaizdo stebejimo kameros, apsaugos kameros, stebejimo kameros: allse.lt
    Vilnius airport transfer vilniusairporttransfer.lt
    Rod  Lewi Rod Lewi
    Jul. 7, 2010 at 9:33am
Registered readers are invited to post a comment. To encourage fruitful discussion, please keep your comments relevant, brief and courteous. Offensive, irrelevant, nonsensical and commercial posts will not be published. (All links will be removed from comments.)

You must register with Science News to add a comment. To log-in click here. To register as a new user, follow this link.

Follow Us