Slashdot Mirror


Magician Turned Professor Talks About the Math Behind Shuffling Cards

An anonymous reader writes with this story about magician and professor of mathematics and statistics at Stanford University Persi Diaconis. "Now a professor of mathematics and statistics at Stanford University, Diaconis has employed his intuition about cards, which he calls 'the poetry of magic,' in a wide range of settings. Once, for example, he helped decode messages passed between inmates at a California state prison by using small random 'shuffles' to gradually improve a decryption key. He has also analyzed Bose-Einstein condensation — in which a collection of ultra-cold atoms coalesces into a single 'superatom' — by envisioning the atoms as rows of cards moving around. This makes them 'friendly,' said Diaconis, whose speech still carries the inflections of his native New York City. 'We all have our own basic images that we translate things into, and for me cards were where I started.' In 1992, Diaconis famously proved — along with the mathematician Dave Bayer of Columbia University — that it takes about seven ordinary riffle shuffles to randomize a deck. Over the years, Diaconis and his students and colleagues have successfully analyzed the effectiveness of almost every type of shuffle people use in ordinary life."

63 comments

  1. Tip: The best method to shuffle by Anonymous Coward · · Score: 5, Funny

    to complete randomness, is to leave an open pack sitting on the floor and let loose the kittens.

    1. Re:Tip: The best method to shuffle by njnnja · · Score: 3, Informative

      Cats aren't taking pleasure in tormenting prey, or playing with the mouse, they are tiring out an animal that has teeth and claws and could potentially hurt the cat. In the wild, even if a predator manages to kill the prey, if that prey manages to wound the predator so that the next time it goes on the hunt, it is not so strong or sharp, the predator is in trouble.

      Have you ever gone fishing? The best way to catch many kinds of fish is to fight it for a while and tire it out. That's the hunting methodology that cats have evolved to use.

    2. Re: Tip: The best method to shuffle by ShanghaiBill · · Score: 3, Informative

      What would motivate a rabbit, horse or dog to eat its own shit?

      At least in the case of rabbits, it is normal behavior. All rabbits do it. They eat high-cellulose diets, and require bacteria to break down the fiber. Cows manage that by having multiple stomachs and a long digestive tract. But rabbits are too small for that, so they use two passes. After the first pass, the poop comes out soft and green, and is re-eaten as it emerges from the anus. After the second pass, the poop is hard black pebbles, and is not eaten.

      Many animals will eat the feces of their young to get rid of the odor that may attract predators.

      Most dogs stop eating poop as they mature. Puppies often do it, but adult dogs usually don't, unless they are nursing a mother, which often eat the puppy poop. Folklore has it that you can stop a dog from eating poop by mixing mashed pumpkin into their food.

    3. Re: Tip: The best method to shuffle by Snotnose · · Score: 0

      What would motivate a rabbit, horse or dog to eat its own shit?

      For a lot of animals their digestive system can't extract all the nutrients in one pass. By giving the food a second pass through the digestive tract they get more nutrients.

    4. Re:Tip: The best method to shuffle by Livius · · Score: 1

      The kittens want you to believe that the outcome would be random.

    5. Re:Tip: The best method to shuffle by Tyler+Durden · · Score: 1

      Just because there is a good reason for cats to torment their prey doesn't mean they aren't enjoying it. Hunting is part of their nature, and it does seem that more intelligent animals get joy out of doing what they were born to do.

      I mean a household cat doesn't need to hunt to eat, but when left outside it will hunt with gusto. Its joy is inflicting agony and death.

      --
      Happy people make bad consumers.
    6. Re:Tip: The best method to shuffle by Bengie · · Score: 1

      I had a cat that brought back a baby wild rabbit. It carried the rabbit at the scuff like a kitten and was very gentle with it. I was not expecting that based on how excited it got about small animals. My cousin's cat pounced on his hamster and looked about to kill it when he smacked the cat. After that, the cat would groom the hamster and would sleep through the hamster walking all over it.

      Cats can be interesting when it comes to prey.

  2. Oblig Simpsons by bangular · · Score: 4, Funny

    I'm a very special type of magician, I'm a MATH-emagician

    1. Re:Oblig Simpsons by MetalliQaZ · · Score: 1

      Simpsons reference AND a Chappelle's reference? I think we just became best friends

      --
      "Here Lies Philip J. Fry, named for his uncle, to carry on his spirit"
    2. Re:Oblig Simpsons by sconeu · · Score: 2

      Phantom Tollbooth did it first!

      --
      General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
  3. seven ordinary shuffles by Anonymous Coward · · Score: 0

    "... that it takes about seven ordinary riffle shuffles to randomize a deck."

    This often cited proof depends on a non-unique definition of random-- random relative to a cards original postion in the deck or relative to the position of another card. The number of shuffles varies with this definition. This has been proven.

    1. Re:seven ordinary shuffles by sexconker · · Score: 2

      And it varies with each individual shuffler, deck of cards, etc.
      To call such a thing a "proof" is an insult to actual mathematical proofs. To use such a definition of "random" is outright blasphemy.

    2. Re:seven ordinary shuffles by njnnja · · Score: 1

      The Gilbert-Shannon-Reeds model of shuffling is a textbook example precisely because it is both mathematically tractable and a pretty good model of how a riffle shuffle actually distributes cards. It is so good a model, that I would argue that if your shuffling technique isn't well-approximated by the model, then you aren't doing a riffle shuffle.

      And his definition of "random" is not "outright blasphemy." To the contrary, the definition is basically "the greatest difference in probability of any particular subset of the universe of possible distributions between a perfectly uniform distribution (the distribution of an infinite number of shuffles) and the distribution you actually have after a finite number of shuffles." As the Wikipedia article mentions, another alternative would be to use a measure of entropy instead of the statistical distance, but nevertheless statistical distance is a pretty good way to do it.

    3. Re:seven ordinary shuffles by sexconker · · Score: 1

      That's a terrible definition of random. Entropy and statistics have nothing to do with randomness.

      Something is random if it is not due to any deterministic cause. Yes, that definition means there is no such thing as a random event, a random number, etc in a deterministic universe. And yes, that is the correct definition.
      In a deterministic universe there is no such thing as a "random" ordering for a deck of cards as there is no such thing as "random".

      Beyond that, their definition is based on patterning a deck after a deck that is the result of an infinite number of shuffles. If the shuffle is performed the same way each time, then the order of the deck will be completely predictable. If the shuffle is not performed the same way each time, then it does not converge into any high entropy or statistically noise state to which you can compare your deck after a finite number of shuffles. Given an infinite number of shuffles there are an infinite number of times the deck is ordered perfectly, and many more infinite number of times the deck is in a low entropy state or statistically clean.

      And if you're deliberately seeking to get the deck into some high entropy state by ensuring a semi-regular shuffle pattern and a target number of shuffles, then you're not getting a random deck.

      If you believe in a probabilistic universe, then you can have randmoness, but you can never know if something is actually random or not.

      This is fundamental shit.

    4. Re:seven ordinary shuffles by njnnja · · Score: 1

      You are not even wrong. Measure-theoretic probability has proven itself as an exceptionally accurate model of highly complex, yet fully deterministic, phenomena that cannot be predicted well using other means. Such as the shuffling of a deck of cards, slightly different each time, but similar enough to be able to build a model of its behavior.

      You called it "random," not me. I would call it "\underset {A\subset S_n} {sup} |Q^{*k}(A) - U(A)|" and then label it as "random" because that is what most laypeople would recognize as being like "randomness". If you have a different definition of "random" that's fine, but you can't argue against the proof that 7 shuffles is sufficient to reduce the total variation distance to stationarity from about 1.0 to about 0.33. If you disagree, please show your work.

  4. Numberphile interviews by myrrdyn · · Score: 5, Interesting

    Brady Haran on Numberphile has a series of interviews with Persi Diaconis: https://www.youtube.com/playli...

    --
    Elen sìla lùmenn' omentielvo
    1. Re:Numberphile interviews by Barny · · Score: 1

      Dang it, I had my link all ready and you beat me to it. Damn good series, very interesting in that he describes in simpler terms why and how it is worked out.

      --
      ...
      /me sighs
    2. Re:Numberphile interviews by RedWizzard · · Score: 1

      I suspect the Numberphile videos about shuffling inspired this article.

  5. Perfect shuffle by Anonymous Coward · · Score: 1, Interesting

    If you do 13 perfect shuffles (deck cut in exactly half, one card from each half going on top of the other), you will end up with the same deck. So it's not surprising that 7 "shuffles" would maximize entropy, by how they are measuring it (where does the top card end up, are there adjacent cards still "stuck"). You do end up with interesting pattern on a perfect shuffle using a sorted deck.

    --sf

    1. Re:Perfect shuffle by trb · · Score: 2
      8 perfect (faro out) shuffles will get you back home. You can do this with code, and there are youtube videos that claim to show it.

      http://en.wikipedia.org/wiki/F...

  6. First request for Slashdot video...EVAR by xxxJonBoyxxx · · Score: 3

    This topic might have warranted a video, considering it's a demo. It would sure beat all the "some dude talks about something for flipping forever" videos Slashdice keeps trying to dump on us instead.

    1. Re:First request for Slashdot video...EVAR by Anonymous Coward · · Score: 1

      I'm still waiting for an option to find sex partners with /. video.

    2. Re:First request for Slashdot video...EVAR by Anonymous Coward · · Score: 0

      "T.R.U.!"

      -2 Chainz

    3. Re:First request for Slashdot video...EVAR by myrrdyn · · Score: 1

      This topic might have warranted a video, considering it's a demo. It would sure beat all the "some dude talks about something for flipping forever" videos Slashdice keeps trying to dump on us instead.

      As I already pointed out in a different post, there are some video interviews on Numberphile:
      https://www.youtube.com/playli...

      Ok, it's not a Slashdot video but hey :-)

      --
      Elen sìla lùmenn' omentielvo
    4. Re:First request for Slashdot video...EVAR by umghhh · · Score: 1

      what would any /.er need a sex partner for?

    5. Re:First request for Slashdot video...EVAR by Anonymous Coward · · Score: 0

      Get a Fleshlight. It's a lot easier on your bank account.

    6. Re:First request for Slashdot video...EVAR by DrunkenTerror · · Score: 1

      Even greasy Yoda dolls get a taste for some strange from time to time.

    7. Re:First request for Slashdot video...EVAR by Anonymous Coward · · Score: 0

      Get a Fleshlight. It's a lot easier on your bank account.

      Add a TENS unit and you'll never date again.

  7. I heard his seven shuffle result long before 92. by thomasoa · · Score: 1

    Hmm, I recall learning the seven shuffle result when I was in math grad school in the 80s (from Prof Diaconus himself.) Did he not publish it until '92?

  8. What is the objective of the research? by Trachman · · Score: 1

    First of all, my respect to devoted professor and mathematician who is able to concentrate into observation and to think it through various aspects.

    I have read article carefully and what it says is that certain type of shuffling produces desired random sequence of cards.

    Also, consequently, we have mathematician who is trying to prove statistical correlation between how much time is spent mixing (smooching) and the randomness.

    It can be proved empirically that this is a correct theory - the longer you shuffle cards, the more random sequence you have.

    My question is..... what are the practical applications of this observation and what exactly mathematician is trying to prove.

    1. Re:What is the objective of the research? by Anonymous Coward · · Score: 0

      As always with maths research you have to understand a bit more about the mathematical version of the problem and it’s solution to see why it’s of any importance. In this case, Diakonis’ work on riffle shuffles and other techniques was a very interesting merging of abstract algebra and statistics. This has led to questions in algebra that were never considered (for example to do with limits of dimensions of representations of Lie groups), which then leads to new techniques in this field which is very closely connected to theoretical physics. It’s extremely difficult to know ahead of time where mathematical developments will be useful, and asking what are the practical applications of one piece of research is like asking what is the point of any given steel beam in a building.

    2. Re:What is the objective of the research? by Obfuscant · · Score: 1

      It can be proved empirically that this is a correct theory - the longer you shuffle cards, the more random sequence you have.

      Not for a riffle-shuffle, which is what most people do. For a riffle, the more you do IMPERFECT shuffles, the more random, but for every perfect riffle shuffle the output will be completely predictable.

      A wash is a much more random shuffle, which is why casinos that don't have machines to shuffle and use a single deck will do a wash. I have no idea how the shuffle machines operate, they're literally a black box.

    3. Re:What is the objective of the research? by Anonymous Coward · · Score: 1

      It can be proved empirically that this is a correct theory - the longer you shuffle cards, the more random sequence you have.

      that's not true at all. After some point more shuffling will make the set less random the more times you shuffle. How do you find that point?

      It's really not all that simple, but in many fields it could be important.

    4. Re:What is the objective of the research? by aaaaaaargh! · · Score: 1

      what are the practical applications of this observation

      Mathematicians don't need practical applications. When they speak about "applications" they mean "applications to other fields of mathematics". And that is good so.

      That being said, I know Diaconis primarily for his earlier work on ranking methods, which have many practical applications in CS -- like page ranking algorithms, for instance.

    5. Re:What is the objective of the research? by Anonymous Coward · · Score: 0

      No; adding more entropy does not reduce entropy.

      Perhaps you are thinking of the interesting trick that if you do a perfect riffle shuffle repeatedly, you end up back where you started.

      But we're talking about random riffle shuffles here, where you're not letting exactly one card fall left, right, left, right each time.

      Doing repeated non-perfect varying riffle shuffles does not reduce the randomization.

    6. Re:What is the objective of the research? by Anonymous Coward · · Score: 0

      An obvious practical application is the direct application to people playing card games, who want to randomize their deck but don't want to spend an unnecessarily long time doing it.

  9. I want a mathemetician turned magician by Anonymous Coward · · Score: 0

    But that's highly unlikely. I didn't RTFA largely because the summary included the word intuition.

  10. Magician Turned Professor... by wonkey_monkey · · Score: 1

    Magician Turned Professor

    ...into a frog.

    --
    systemd is Roko's Basilisk.
    1. Re:Magician Turned Professor... by bobbied · · Score: 1

      Magician Turned Professor

      ...into a frog.

      If kissed he's a prince too...

      --
      "File to fit, pound to insert, paint to match" - Aircraft Maintenance 101
  11. Mental Hopscotch by Anonymous Coward · · Score: 0

    Mental Hopscotch
    Mental Hopscotch
    Mental Hopscotch
    Do me shuffle me rill me dump me

  12. Nice picture of card shuffling by Anonymous Coward · · Score: 0

    This blog post is rather more interesting than the (inaccurate) post above:
    https://mathymcmatherson.wordpress.com/2015/04/15/mild-obsessions/

  13. So, by Anonymous Coward · · Score: 0

    every type of shuffle people use in ordinary life

    Which shuffle should I use in my ordinary life then? I'm ashamed that I survived so long without using one.

  14. Perfect riffle shuffle by hired+killer · · Score: 1

    Most people are not aware that a perfect riffle shuffle on a deck of cards returns the deck to it's original state at eight shuffles. This means an assumption of imperfection for seven shuffles.

    It is highly probabilistic that a perfect riffle shuffle never occur. It takes some effort to replicate to perfect shuffle.

    1. Re:Perfect riffle shuffle by Anonymous Coward · · Score: 0

      On the other hand, the first thing you learn when you experiment with deck-stacking is that it takes very little effort to make certain non-perfect riffles that can also guarantee non-randomness. For example, it is trivial to do a riffle shuffle that will keep the bottom card in place-- when you cut the deck, note which half was the bottom. When you start the shuffle, start that side first, so that some of the cards from that side drop before any cards from the other side do. That ensures that the bottom card (and indeed, usually the bottom five or six cards) of the post-shuffle are the same as they were pre-shuffle. Repeat N times, and then deal from the bottom of the deck...

    2. Re: Perfect riffle shuffle by Anonymous Coward · · Score: 1

      It is actually pretty easy to do once you get the knack for it. Cut the deck in half, square the ends, place the ends against each other with about a three eights inch offset, push the halves together firmly, and slightly twist the opposite ends toward you. If it is a new deck, the cards will basically interlace themselves. perfectly.
      Yes, I did have a misspent childhood.

    3. Re:Perfect riffle shuffle by Anonymous Coward · · Score: 0

      Their definition of a riffle shuffle IIRC is a mathematical one, where you divide the deck in 2 stacks and take a random number of cards from each stack in turn (don't recall if there was an upper limit involved). Certainly a human doing 7 riffle shuffles gives you a completely different result.

      Note that I recollect this from memory of reading about this research some time between 1 and 2 decades ago. I think the definition of old news has just been re-invented by slashdot.

  15. Re:I heard his seven shuffle result long before 92 by Anonymous Coward · · Score: 0

    My guess is he suspected it but did not have the right tools to prove it. Some people are like that with math. They can 'see it' but not have the correct proof to write it down.

    The idea makes sense. Eventually it is random. But *when* is the question.

  16. All Shuffles? by jburgess · · Score: 0

    "Over the years, Diaconis and his students and colleagues have successfully analyzed the effectiveness of almost every type of shuffle people use in ordinary life."

    All Shuffles? What about the Truffle Shuffle? After all, that is the most important shuffle I can come up with.

    1. Re: All Shuffles? by Anonymous Coward · · Score: 0

      ... and the Kansas City Shuffle

      but that never ends well

  17. I hope Kevin Spacey is booked solid by Anonymous Coward · · Score: 0

    and he won't be available to be cast in this role. When the film version is announced, of course.

  18. Coin Flip by Anonymous Coward · · Score: 0

    Diaconis also did a wonderful study on how human flipped coins aren't fair some years back.

    https://statweb.stanford.edu/~susan/papers/headswithJ.pdf

  19. objective of the research: The perfect shuffle. by TiggertheMad · · Score: 2

    It can be proved empirically that this is a correct theory - the longer you shuffle cards, the more random sequence you have.

    Not true. There is a limit to entropy of a collection of objects, and once you reach this limit, any change to the system can only to be a reduction in the degree of entropy in the system. Also, it is entirely possible, (if unlikely) that you can shuffle a randomized deck of cards into sequential order.

    --

    HA! I just wasted some of your bandwidth with a frivolous sig!
    1. Re:objective of the research: The perfect shuffle. by Obfuscant · · Score: 3, Informative

      Also, it is entirely possible, (if unlikely) that you can shuffle a randomized deck of cards into sequential order.

      Random does not mean completely out of order, it means unpredictable. I can roll five dice and come up with a large straight (12345). The random comes from not being able to predict from the previous state (22222 Yahtzee!) what the next state (12356 chance) will be.

      A perfect riffle shuffle is not a random process since you can observe the initial state (123456 e.g) and predict the result (142536). That's true for whatever the starting state is.

  20. Re:I heard his seven shuffle result long before 92 by Anonymous Coward · · Score: 0

    Proof? Have you seen the data? It's basically a curve, and at some point you say, "yea, x% non-random seems small enough for me": http://www.ams.org/images/fcarc-december2010-dk.graph.2.gif

    http://www.ams.org/samplings/feature-column/fcarc-shuffle

  21. Colm Mulcahy -- Math and Cards by 6,28.496 · · Score: 1

    For those who are interested in math and/or card tricks, Colm Mulcahy is a professor of mathematics who often writes about math, cards and card tricks. He writes a blog called Card Colm for the Mathematical Association of America (MAA). He has written a book, Mathematical Card Magic: Fifty-Two New Effects, published by CRC Press.

    A web site contains other interesting information about Mulcahy and his work, including links to past Card Colms.

    Enjoy!

  22. your education dollars at work by Anonymous Coward · · Score: 0

    no wonder the education system sucks, it's just rich kids having fun spending public funds on useless crap