July 3rd, 2024

The Math of Card Shuffling

The article delves into the mathematics of card shuffling, emphasizing riffle shuffling for randomness. It explains the need for seven riffles to shuffle a deck and approximates 236 single card riffles for full shuffling. Visualizations illustrate the process.

Read original articleLink Icon
The Math of Card Shuffling

The article discusses the mathematics behind card shuffling, particularly focusing on the concept of riffle shuffling to achieve randomness in a deck of cards. It explains that seven riffles are needed to completely shuffle a deck of 52 cards. Additionally, it explores the scenario of single card riffles, where it is calculated that approximately 236 single card riffles are required to achieve a fully shuffled deck. The process is detailed through an iterative explanation, showcasing how the bottom card eventually rises to the top through repeated riffles. The article also provides interactive visualizations to demonstrate the movement of cards during the shuffling process. Overall, the piece delves into the intricate calculations and probabilities involved in achieving randomness through card shuffling techniques.

Related

Everyday is a Birthday A Journey to a classic problem through Math and Rust

Everyday is a Birthday A Journey to a classic problem through Math and Rust

This article explores the classic probability problem of ensuring every day of the year is represented by a birthday in a group of people, using mathematical concepts like the Coupon Collector Problem and Inclusion-Exclusion Principle. It calculates needing around 2364 students, adjusting to 2669 with leap days, and discusses the gamma function for probability calculation.

Do not confuse a random variable with its distribution

Do not confuse a random variable with its distribution

In probability theory, a random variable and its distribution are distinct concepts. The random variable depends on random outcomes, while the distribution shows variation patterns. Changing variables or probabilities alters distributions. Examples clarify shared distributions with different outcomes, crucial for interpreting probabilities and simulations.

The Magic of Participatory Randomness

The Magic of Participatory Randomness

Randomness is vital in cryptography, gaming, and civic processes. Techniques like "Finger Dice" enable fair outcomes through participatory randomness, ensuring transparency and trust in provably fair games.

A Quantum Leap in Factoring

A Quantum Leap in Factoring

Recent quantum computing advancements include Peter Shor's Shor algorithm for factoring large numbers and Oded Regev's new scheme reducing gate requirements. Practical implications and implementation challenges persist despite optimism for future cryptography improvements.

Exploring Randomness in JavaScript

Exploring Randomness in JavaScript

This article compares Math.random() and Crypto.getRandomValues() in JavaScript for generating random values. Despite Crypto being more secure, Math.random() suffices for creating color palettes due to speed and perceived randomness.

Link Icon 8 comments
By @Syzygies - 8 months
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.

By @slaymaker1907 - 8 months
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.

By @nyc_pizzadev - 8 months
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.
By @waynecochran - 8 months
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.
By @cal85 - 8 months
> …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.

By @matsemann - 8 months
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
By @veunes - 8 months
Do not know why but still it's a problem for me to shuffle cards
By @jwood27 - 8 months
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