Your Deck of Cards Isn't Actually Shuffled
March 9, 2026 · 54 min read
Cover art by @prynmatica :3
In a standard deck of 52 playing cards, the number of possible orderings is , which is roughly . This number is larger than the number of square meters on the surface of every star in the observable universe. If every human who ever lived shuffled a deck once every second since the Big Bang, humanity would still have witnessed less than an infinitesimal fraction of the possible configurations.
Because that permutation space is so vast, most card players assume that almost any chaotic physical mixing is sufficient to make a deck unpredictable. In casual games, and for decades in commercial casinos, dealers would riffle shuffle a deck three or four times before dealing a hand of blackjack or poker. The reasoning felt intuitive: after four shuffles, every single card has been displaced from its original position, cards from the top and bottom of the deck are thoroughly intertwined, and no adjacent pair from the factory order remains intact.
In 1992, mathematicians Dave Bayer and Persi Diaconis published Trailing the Dovetail Shuffle to its Lair. They proved that this intuition is completely wrong.
After four riffle shuffles, the deck is not random. It is not even partially random in any meaningful statistical sense. The mathematical distance between a four-shuffled deck and genuine randomness is to four decimal places. You can construct bets based on simple card orders where the house has an enormous negative expectation.
Then, between the fifth, sixth, and seventh shuffles, something unusual happens. The distribution of permutations does not slowly drift toward uniform randomness. Instead, it experiences a sharp mathematical phase transition known as the cutoff phenomenon. At six shuffles, the deck remains heavily biased. At seven shuffles, the bias collapses, and the total variation distance drops to .
Here is how the mechanics work.
1. The Gilbert-Shannon-Reeds Model
To analyze a physical shuffle mathematically, we need a realistic model of how humans actually shuffle cards.
A riffle shuffle (or dovetail shuffle) consists of two physical steps:
- The Cut: The dealer cuts the deck of cards into two packets of sizes and .
- The Riffle: The dealer releases the cards from their thumbs so that the two packets interleave into a single combined stack.
In 1955, Edgar Gilbert and Claude Shannon developed a probabilistic model for this process at Bell Labs, which was later independently rediscovered by Jim Reeds in 1981. It is now known as the Gilbert-Shannon-Reeds (GSR) model.
The model rests on two simple assumptions:
Step 1: The Binomial Cut
When a human cuts a deck of cards in half, they rarely divide it into exactly and . Instead, the size of the top packet follows a binomial distribution with parameters and :
For , the average cut size is 26, with standard deviation cards. Almost all cuts land between 20 and 32 cards.
Step 2: Proportional Interleaving
Suppose the left hand holds a packet of cards and the right hand holds a packet of cards. As the dealer lets cards fall from their thumbs, the probability that the next card drops from the left packet is proportional to the size of that packet:
If the left hand holds 30 cards and the right hand holds 10 cards, the next card is three times as likely to drop from the left hand. As cards drop, the packet sizes and shrink until both reach zero.
This physical assumption has an elegant combinatorial consequence: every one of the possible interleavings of the two packets is equally likely.
To see why, notice that if you trace any specific interleaving path backward from cards to zero, the denominator product in the probabilities telescopes, canceling out the packet counts and leaving exactly . Multiplying this by the cut probability , the combinatorial term cancels entirely:
In other words, a GSR riffle shuffle chooses uniformly at random among all possible outcomes of binary assignments to cards.
Diaconis and his collaborators tested this model against slow-motion video footage of professional dealers and amateurs. The physical data matched the Gilbert-Shannon-Reeds distribution with remarkable accuracy.
2. Rising Sequences: The Hidden Invariant
The secret to tracking the GSR shuffle lies in an invariant called a rising sequence.
Number the cards in the deck from to in their initial factory order, with 1 on top and on the bottom. After any number of shuffles, the deck is represented by a permutation .
A rising sequence is a maximal subsequence of cards whose face values increase consecutively by , appearing in left-to-right order in the deck.
Let us illustrate this with a small 6-card deck initially ordered:
Suppose we cut the deck into two packets:
- Left packet:
- Right packet:
Now we interleave them into a new permutation:
How many rising sequences does this permutation have? Let us trace the consecutive numbers:
- Starting with 1: we find , then , then . These form the sequence .
- Starting with the next missing number, 4: we find , then , then . These form the sequence .
Every card belongs to exactly one rising sequence. The permutation has exactly 2 rising sequences.

Now consider the fundamental theorem of riffle shuffles:
Lemma (Rising Sequence Bound):
A single riffle shuffle can produce at most rising sequences.
The reason is elementary: a single riffle shuffle cuts the deck into two ordered packets. When those packets drop onto the table, the relative order of cards within each packet is preserved. The cards from the left packet form one rising sequence, and the cards from the right packet form the second rising sequence. (In the degenerate case where one packet is empty, there is only 1 rising sequence.)
What happens when you shuffle the deck a second time?
Each existing rising sequence can at most be cut in two by the new cut point and interleaved. Therefore:
Theorem (Sequence Doubling):
After independent GSR riffle shuffles, the resulting permutation can have at most rising sequences.
Let us evaluate this bound for a standard 52-card deck:
- After shuffle: at most rising sequences.
- After shuffles: at most rising sequences.
- After shuffles: at most rising sequences.
- After shuffles: at most rising sequences.
- After shuffles: at most rising sequences.
Now pause and consider what a truly random permutation of 52 cards looks like.
3. Eulerian Numbers and the Reachability Barrier
In an average, randomly chosen permutation of cards, how many rising sequences would you expect to find?
The answer comes from classical combinatorics. The number of permutations in the symmetric group that have exactly rising sequences is given by the Eulerian numbers, denoted (or ):
Eulerian numbers are symmetric: . The distribution is bell-shaped and centered at:
For a 52-card deck:
A genuinely random permutation of 52 cards typically has between 23 and 30 rising sequences. Permutations with fewer than 17 rising sequences are astronomically rare:
While sounds like a large number, recall that . The fraction of all permutations having 16 or fewer rising sequences is:
This reveals the reachability barrier:
- After 4 shuffles, the maximum number of rising sequences a deck can possibly have is .
- Therefore, after 4 shuffles, over 99.77% of all possible permutations have probability strictly zero.

You cannot reach them. No matter which cards fall where, 4 shuffles physically cannot generate any permutation that requires 17 or more rising sequences. The dealer has not shuffled the deck into a random state; they have confined it to a microscopic subset comprising less than a quarter of one percent of the permutation group.
Even after 5 shuffles, where , any permutation requiring 33 or more rising sequences has probability exactly zero.
4. The Bayer-Diaconis Probability Formula
In their 1992 paper, Bayer and Diaconis went far beyond counting reachability. They derived the exact probability distribution over the entire symmetric group after shuffles.
Their insight relied on an equivalence between shuffling and reading expansion digits. Consider marking each card with an independent uniform random binary digit in . Sorting the deck stably by this bit (keeping cards with 0 in their initial relative order, followed by cards with 1 in their initial relative order) is precisely a GSR shuffle.
Performing successive shuffles corresponds to assigning each card a random -bit binary label:
and sorting the cards lexicographically by their -bit labels, breaking ties using their initial positions. Since there are possible values for a -bit label, shuffles are equivalent to a single -shuffle, where the deck is cut into packets according to a multinomial distribution and then interleaved.
Using this geometric and algebraic formulation, Bayer and Diaconis proved:
Theorem (Bayer & Diaconis, 1992):
Let be a permutation with rising sequences. The exact probability of arriving at after independent GSR riffle shuffles is:
This is an astonishingly clean formula. The probability of obtaining a permutation does not depend on the individual values of its cards or their complex pairings. It depends solely on a single integer: the number of rising sequences in .
Let us examine what this formula tells us:
- If , then , and the binomial coefficient . The probability is zero, matching our earlier combinatorial bound.
- When becomes large, , and the binomial coefficient can be approximated using Stirling’s expansion: Then , which is the uniform distribution.
5. Total Variation Distance and the Cutoff
To quantify how close the distribution is to the uniform distribution , probabilists use the total variation distance ():
Total variation distance has a concrete operational meaning: it represents the maximum advantage any gambler can achieve on any event over random guessing.
- If , there exists an event that occurs with probability 1 under but with probability near 0 under . The deck is completely non-random.
- If , the distribution is indistinguishable from uniform randomness.
Because is identical for all permutations with the same number of rising sequences , and because there are exactly such permutations, the sum over all configurations collapses to a simple 52-term sum:
Evaluating this sum for yields the exact numbers:
| Shuffles () | Total Variation Distance | Reachable Rising Sequences () |
|---|---|---|
| 1 | 1.0000 | 2 |
| 2 | 1.0000 | 4 |
| 3 | 1.0000 | 8 |
| 4 | 1.0000 | 16 |
| 5 | 0.9237 | 32 |
| 6 | 0.6135 | 64 (all 52) |
| 7 | 0.3341 | all 52 |
| 8 | 0.1672 | all 52 |
| 9 | 0.0854 | all 52 |
| 10 | 0.0429 | all 52 |

For the first four shuffles, the variation distance is effectively pinned at 1.0. The deck is not mixing gradually.
Then, between shuffles 5 and 7, the distance plunges precipitously: from down to . After shuffle 7, each subsequent shuffle cuts the remaining variation distance roughly in half: at 8, at 9, and at 10.
This step-function behavior is known as the cutoff phenomenon. Rather than decaying exponentially from time zero like a standard diffusive physical system, the Markov chain stays far from equilibrium for a fixed duration, and then rapidly transitions to its stationary distribution within a narrow window.
6. The Asymptotic Scaling Law
Why does the cutoff occur at 7 for a 52-card deck? What happens if you shuffle a deck of 100 cards, or 1,000 cards?
Bayer and Diaconis proved that as , the critical number of shuffles scales logarithmically with the deck size:
where is a constant offset parameterizing the position inside the transition window.
Specifically, if you set , then as :
where is the standard normal cumulative distribution function.
Let us check the leading term for a standard deck:
Finite-size combinatorial corrections shift the inflection point slightly to the left, centering the drop between and .
Contrast this scaling with other types of physical shuffles:
- Top-to-Random Shuffle: Take the top card and insert it at a uniform random position in the deck. The mixing time is . For 52 cards, this requires roughly moves.
- Random Transpositions: Pick two cards uniformly at random and swap them. The mixing time is , requiring roughly 100 swaps.
- Overhand Shuffle: The casual shuffling method where small packets are slipped from one hand to the other. Its mixing time is . To randomize a 52-card deck using overhand shuffles alone, you need approximately 2,500 shuffles.
Because the riffle shuffle operates on all cards simultaneously through binary interleaving, it requires only operations, making it one of the most efficient physical mixing algorithms known.
7. Python Implementation: Verifying the Exact Numbers
You do not have to take the theorem on faith. The exact total variation distances can be computed directly using Python’s standard library:
import math
def eulerian_number(n: int, r: int) -> int: """ Computes the Eulerian number A(n, r): the number of permutations in S_n having exactly r rising sequences. """ return sum( (-1)**j * math.comb(n + 1, j) * ((r - j)**n) for j in range(r + 1) )
def bayer_diaconis_tv(n: int, max_k: int = 10) -> list[tuple[int, float]]: """ Computes exact total variation distance for a deck of size n after k = 1 ... max_k Gilbert-Shannon-Reeds riffle shuffles. """ n_factorial = math.factorial(n)
# Precompute Eulerian numbers A(n, 1) through A(n, n) eulerian = [eulerian_number(n, r) for r in range(1, n + 1)] assert sum(eulerian) == n_factorial, "Eulerian sum must equal n!"
results = [] for k in range(1, max_k + 1): two_k = 2**k two_kn = 2**(k * n)
tv_numerator = 0 for r in range(1, n + 1): count = eulerian[r - 1] # Q^k(sigma) = comb(2^k + n - r, n) / 2^(k*n) # Uniform U(sigma) = 1 / n! # We scale both terms by n! * 2^(kn) to work with exact integers: prob_scaled = math.comb(two_k + n - r, n) * n_factorial unif_scaled = two_kn tv_numerator += count * abs(prob_scaled - unif_scaled)
# Divide by 2 * n! * 2^(kn) tv_distance = tv_numerator / (2 * n_factorial * two_kn) results.append((k, tv_distance))
return results
if __name__ == "__main__": n = 52 print(f"Bayer-Diaconis Total Variation Distance for n = {n}:") print(f"{'k':>3} | {'TV Distance':>12}") print("-" * 18) for k, tv in bayer_diaconis_tv(n, max_k=10): print(f"{k:3d} | {tv:12.4f}")Running this script takes less than one second and outputs the exact values derived by Bayer and Diaconis in 1992:
Bayer-Diaconis Total Variation Distance for n = 52: k | TV Distance------------------ 1 | 1.0000 2 | 1.0000 3 | 1.0000 4 | 1.0000 5 | 0.9237 6 | 0.6135 7 | 0.3341 8 | 0.1672 9 | 0.0854 10 | 0.04298. Exploiting the Defect: A Simple Practical Test
Why does a total variation distance of matter to a player at a table?
Suppose you are playing a game where a dealer shuffles a new deck 3 times and begins dealing cards one by one from the top. Can you exploit the order?
Yes, easily. Consider this simple prediction rule:
Guess: Whenever a card is dealt, guess that the next card will have a higher value if the current card belongs to an unfinished rising sequence.
Because 3 shuffles can produce at most rising sequences, the cards in the deck are partitioned into at most 8 long monotonic threads. On average, each thread contains cards.
Under genuine randomness, the chance that the next card is higher than the current card is roughly . But after only 3 or 4 shuffles:
- If the card just dealt is a 4, there is a very high probability that the 5 from that same original packet is sitting just a few cards deeper in the stack.
- The probability of correctly guessing whether the next card is higher or lower rises from to over .
Persi Diaconis once demonstrated this to casino executives. He bet that after 4 shuffles, he could consistently predict whether upcoming cards were red or black, high or low, with statistical significance. When they saw the results, several major casino operators changed their dealer procedures, requiring automated shuffling machines or mandating at least seven riffle shuffles combined with a box cut before dealing.
9. Conclusion
Most people stop after three or four riffle shuffles because the cards already look thoroughly mixed. Every card has moved, neighboring pairs have been split up, and red and black cards alternate across the spread. But local disorder is deceptive.
A riffle shuffle only doubles the number of rising sequences each time it is performed. Because a typical 52-card permutation requires around 26 rising sequences, four shuffles leave more than 99% of all possible configurations completely out of reach. The variation distance does not decay gradually from the start; it stays pinned near 1.0 until a sharp cutoff between the fifth and seventh shuffle. It takes seven riffles to actually wash out that structural memory. Anything less, and the deck still retains a clear imprint of where it began.