Hacker News new | past | comments | ask | show | jobs | submit login
The Math of Card Shuffling (fredhohman.com)
107 points by Anon84 10 months ago | hide | past | favorite | 27 comments



Pretty funny that this cites a 2015 Numberphile video, considering that my paper with Persi Diaconis was published in 1992.

(You know you're on to something when so many people misquote and misinterpret your result, and say it sucks!)

Of the many formulations of Gilbert-Shannon-Reeds, an easy one to generalize is running the shuffle in reverse. One could flip a fair coin for each card, to decide if it flies up to the right or left hand. Equivalently, let heads fly up to the same hand as before, and let tails fly up to the other hand. As an unfair coin approaches always tails, the inverse shuffle becomes smoother, approaching a perfect shuffle, which Persi can easily do.

One way to measure how smoothly one shuffles is to flip one hand's packet over before shuffling, then count face up / face down runs. For a perfect shuffle, there will be 52 singleton runs: up, down, up, down... For GSR shuffles there will be 26 1/2 runs on average. Experienced human shuffles tend to exhibit 30 to 40 runs. While only GSR can be solved in closed form, one can run simulations to see what happens with smoother shuffles. As a somewhat surprising coincidence, one approaches randomness most quickly with shuffles corresponding to 30 to 40 runs.



yes


I wish the 7 shuffle thing would stop getting repeated everywhere. It’s based off a faulty model, particularly for sleeved cards, since if we consider the deck as two piles left (L) and right (R), Pr[L|R] (the probability of taking from the left pile given the last draw was from the right), should be about 0.5 but is nearly 1 in many cases.

The riffle shuffle also has to be one of the only things you actually get worse at the more you practice it.


Here is a bit more realistic model of the riffle shuffle. These results show that you need between 3 to 8 riffle shuffles, depending on your skill. Notably, the number of needed shuffles actually does get lower as you get better, i.e., less clumping is better: http://blog.maxshinnpotential.com/2017/11/05/optimality-in-c...


The other thing is that the chaotic pile on the table, well-mixed, is about as fast as 7 riffles mixed with cuts and probably (my personal experience) equally mixed.

Just makes you feel like a child.


The other thing I don't like about it is that many cards will be flipped upside down which is very annoying for games like MTG.


If you take enough space on the table it's possible to do without flipping any cards. Still quite a palaver though.


Definitely haven't been getting worse at the riffle shuffle. But one of my more nerdy gaming buddies doesn't allow any of his cards to be riffled as it degrades the cards.


You get worse w more practice? Explain. I have been practicing the riffle shuffle w/o using the table and keeping the cards contained -- am I going to get worse at it?


Yes, you’ll get the alternating pile phenomenon more and more often. In reality, big “clumps” of cards from one pile or the other actually improve the randomization. In the extreme, this becomes the Faro shuffle https://en.m.wikipedia.org/wiki/Faro_shuffle

From a probabilistic standpoint, even if it isn’t a perfect Faro shuffle, almost-Faro shuffling clearly introduces far fewer bits of entropy which is less than ideal.


I wish! Yes, the better you get at riffle shuffling, the more it will approximate a faro shuffle (meaning less "clumps" and more singles alternating) in some parts of the deck, but it's the repetition that makes it random. If you have accidentally mastered a perfect tabled faro without deliberate practice, I'd like to shake your hand and read your book (or video) on the technique!

Perhaps we can caveat that the person is not cutting perfectly at 26 every time and performing perfect out faros, then we can assume they'll be mixed enough. :-)

It's been a while since I've read Persi Diaconis' paper (who coined the 7 shuffles thing), but I believe all your main concerns were addressed. Not sure about the sleeved deck thing, that wasn't probably a consideration.


Yes, sleeves weren't much of a thing until the 2000s and they do seem to make a big difference in my experience.


To try to account for that, I purposely alternate thin and chunky interleaving when I riffle shuffle (the customary seven times :).


Check out Jason Ladanye. He’s a magician who uses shuffle math to place cards exactly where he wants them to be in the deck. Both impressive and scary.


Go see him in person. He’s now doing in person shows. I had to see it live in order to really believe he was doing what he showed on his social media. Absolutely mind blowing. He’s my favorite


Ha, came here to post about Ladayne. I’ve been watching all his 2-minute shorts and I still can’t wrap my brain around the mental/mathematical skill, or the astounding precision of his fingers.

Another takeaway is the jaw-dropping amount of practice he’s put into it, and his total dedication to perfection (zero mistakes allowed, ever). He speaks at length about this in interviews, and in fact part of his act is to explain that it is not magic at all, but his full commitment to mastering the craft. Something we can all reflect on.


Jason Ladanye is a remarkable magician


I have played Pinochle w friends who always wanted the dealer to shuffle the deck less since they believed that this would more likely result in good/interesting hands (four of kind, straight, pinochle...). This seems to stem from the notion that randomness looks different or is less interesting. If all sequence of cards are equally likely, the ratio of interesting hands to all hands seems worse for a less shuffled deck since the cards are interleaved throughout all the players.


There's a Dutch card game called Rikken that intentionally incorporates bad shuffling. It's a trick-taking game, so the cards get clumped by suit during the hand, and you shuffle very lightly between hands. After shuffling, the cards are dealt several at a time to each player, so players tend to get much more suited hands than with a well-shuffled deck.


This is true if you deal one card at a time. If you deal 2 by 2 or 3 by 3 on the other hand...


> …an ordering that has likely never existed before. In other words, it’s unlikely you’ll ever shuffle two decks the same.

This is an understatement. In fact it is virtually certain that no two shuffled decks of 52 cards have ever been in the same order, across all history. That’s how big 52! is. In fact, to get a 50% chance of any two shuffles matching, you’d need to shuffle a billion decks of cards every second for 4x10e17 years.


Once saw a talk by Roger Antonsen where he did various visualizations of shuffles (but using 64 cards I think for the even splits). Quitw cool images https://rantonse.org/art/2018-07-25


The deep connection between mathematics, art and magic


Do not know why but still it's a problem for me to shuffle cards


My mom put a deck of cards in my hand before I could walk, so i ended up being the one to teach all my friends in school. It takes a while to get it down


I tried to make a model of my own shuffling. Blog post in work, but some interesting bits: https://jacobw.xyz/posts/005_shuffle/#data_exploration




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: