crtdrops
NOTE · ENGLISH ·

What a shuffled deck still remembers

From 1 to 10 riffles under the GSR model, bars for the exact distance to a random deck: 1.000 through the fourth, 0.924 after five, 0.614 after six, 0.334 after seven and 0.043 after ten. On the right, after three riffles: in place, 1.14 (at random, 1); rising sequences, 7.96 (at random, 26.50); exact distance, 1.000; and after five perfect faros, 32 sequences and 0 bits of randomness.

I have played poker at home with friends and in an online card room, and I know the three common ways to shuffle: the riffle, which splits the deck in two and interleaves the halves; the overhand, which drops blocks from one hand to the other; and mixing the cards face down on the table. At the home games I never wrote down how many times the deck was shuffled each hand. But one question stayed with me: does a deck that looks mixed really lose the structure it had?

This note has no physical shuffles yet: no real deck is measured here, mine or anyone’s. What follows is what can be proven with a mathematical model and what comes out of simulating it, and at the end, what that does not let you conclude. It is the math of the cards, not an invitation to gamble. Every figure from the model and the simulation comes from the code of the tool that goes with this note, with its seed, so you can repeat it.

Four ways to measure the order that is left

The deck starts in order: ♠ A…K, ♥ A…K, ♣ A…K, ♦ A…K. After shuffling, you can measure how much it still looks like that order in four ways:

Each one looks at a different structure, and that matters later.

What is proven: the riffle model

The Gilbert, Shannon and Reeds (GSR) model describes a riffle like this: the cut comes from a binomial, like counting heads in 52 coin flips, and cards drop from the two packets with probability proportional to how many each one has left. In 1992, Dave Bayer and Persi Diaconis proved that, under that model, the probability of an order after k riffles depends only on how many rising sequences it has. With that, you can compute exactly, without simulating, how far the deck is from a random one.

Riffles Distance to random Randomness so far (bits) Expected sequences
1 1.000 52.00 2.00
3 1.000 155.71 7.95
4 1.000 198.31 14.10
5 0.924 217.64 19.61
6 0.614 223.51 22.95
7 0.334 225.06 24.71
8 0.167 225.45 25.60
10 0.043 225.57 26.28
Random 0 225.58 26.50

The distance is total variation distance: 1 means someone with the right test always tells that deck apart from a random one; 0, never. After four riffles it is still 1.000. After six, 0.614. After seven it drops to 0.334, and from there it halves with each extra riffle. That is where the famous “seven” comes from.

There is also a bound that does not depend on any table. A random deck has log2(52!) = 225.58 bits of uncertainty. A GSR riffle puts in at most 52 bits, one per card. Four riffles are not enough even in the best case: just to be able to get there, it takes at least five.

And a rule that holds for any riffle, whoever does it: it at most doubles the rising sequences. With k clean riffles there cannot be more than 2k. If a deck “shuffled three times” has 12 sequences, there was something besides three riffles, or a mistake when it was copied.

What is simulated: a thousand decks per condition

This is what a simulated deck looks like after a single riffle. The cut split the first 22 cards (♠ A…K and ♥ A…9) from the other 30 (♥ 10…K, ♣ and ♦); each packet kept its order and the riffle only interleaved them. That is why it has exactly 2 rising sequences, even though no card stayed in its place. It is a simulation of the model, not a photo of a real deck.

A simulated deck after one GSR riffle, in 4 rows of 13: the spades and the hearts from ace to 9 interleaved with the hearts from 10 to king, the clubs and the diamonds, each group in its order. Marked as a simulation, not a real photo.

For the other measures I simulated 1,000 decks for each number of riffles, with seed 1, each one starting in order:

Riffles In place Sequences Pairs together Relative order
0 (in order) 52 1 51 1.000
1 1.95 2.00 25.59 0.749
2 1.32 4.00 12.77 0.627
3 1.14 7.96 6.25 0.562
4 1.03 14.07 3.45 0.532
5 1.03 19.50 1.99 0.514
7 1.02 24.69 1.21 0.505
10 1.00 26.22 1.02 0.504
Random 1 26.50 0.98 0.500

Look at the “In place” column. After three riffles it is already at 1.14, almost the same as a random deck. If that were all you measured, you would say three are enough. But in that same row the sequences are at 7.96 out of 26.50, there are still six pairs together where a random deck would have one, and the exact distance is still 1.000: the deck keeps so much structure that it can always be told apart from a random one.

Sequences are the slowest measure. Even after seven riffles, the central 90 % of GSR decks have between 21 and 28, and that of a random deck, between 23 and 30. The two ranges overlap: with a single deck you cannot tell whether it got seven riffles or is random. The difference shows up in the average of many.

Few cards in place does not prove randomness

The clearest counterexample is the perfect faro: split the deck into two exact halves of 26 and alternate card by card, keeping the top card on top. It has no randomness at all; its entropy is zero. And still:

Faros In place Sequences Pairs together Relative order
4 4 16 0 0.525
5 2 32 0 0.565
8 52 1 51 1.000

After five faros, the deck has two cards in place, no pairs together and 32 rising sequences, more than a random deck. By two of the measures it looks better shuffled than a random one. After eight, it is back exactly in the starting order.

That is why no single measure says a deck is well shuffled. Each one looks at one structure, and a shuffle with no randomness can erase exactly the one you are looking at. My hunch, which this note does not prove: a very even riffle by hand looks more like a faro, so it would mix less than it seems.

The other ways to shuffle

The table above holds for the riffle under the GSR model. For the other two ways I have no count of my own, only what the sources say, and they do not fully agree:

What this note does not let you conclude

Try it with your decks

To try it with your decks, there is Is it well shuffled?: it runs in the browser, computes the exact table, simulates decks with the seed you choose and has a box to paste the orders of real decks. The experiment is simple: put the deck in order, do k riffles with no cuts or overhand passes, and write down the 52 cards from top to bottom. Every deck has to start in order again. The tool checks that all 52 are there with no repeats, flags a deck with more sequences than k riffles allow, and compares it against the model. It sends nothing.

Shuffling is not just moving the cards around. It is reducing the information that the current order still keeps about the previous one. A deck can look mixed and still remember where it came from; the useful question is not whether we shuffle, but how much randomness we are really putting in.

Israel Negrete Lepe is an electronics engineer. Twenty-five years making different systems work together under real conditions: from the sensor, the vehicle or the transaction to the backend, the data, security and operations. Today, increasingly, edge AI. I take on projects by the hour or by deliverable: israel0negrete@gmail.com.