StatisticsLab

How many shuffles does a deck need

Seven riffle shuffles (split the deck in two, let the packets fall interleaved) leave a 52-card deck 0.334 away from uniform in total variation. Put that deck beside one a computer arranged at random: even the shrewdest check anyone can run identifies the shuffled one only 66.7 percent of the time, against 50 percent for a guess. Measured by information, 3.52 percent survives five shuffles; for colours alone the separation distance is 0.317 by the sixth; the full order is still 0.278 away after twelve. The exact table here was recomputed in exact integer arithmetic and agrees with the 1992 original.

. My stochastic calculus lecturer, Chii-Ruey Hwang, cancelled a week of class and told us all to go; he was also one of the two interviewers two days before the lectures. The room was AstroMath 202, my favourite room on campus.

A new deck comes out of its box with each suit running from ace to king. You start shuffling. After how many shuffles can you deal?

Seven. The answer comes from a 1992 paper in the Annals of Applied Probability, . The number holds only when three things are true at once: the deck has 52 cards, the shuffle is a (split the deck in two and let the packets fall interleaved, the way cards are usually shuffled), and the measure of how far the deck still sits from random is . Change the deck or change the distance and a different number comes out.

. The question he wanted answered came from the table: how much of the original order survives a shuffle.

What one shuffle leaves of the original order

. Every number below is computed under that model.

One shuffle divides the original order in two: the cards from the left packet still ascend among themselves, and so do those from the right. Such a maximal ascending run is a rising sequence, a second shuffle splits each run into at most two, and after kk shuffles the deck holds at most 2k2^k of them.

1/7·Start

52 cards in order, 1 to 52, bar height showing the card's value: the whole deck is one rising sequence, a single staircase.

. Do that kk times and every card carries a kk-bit label, with the deck sorted lexicographically by label. There are only 2k2^k labels, so the deck falls into at most 2k2^k groups, which read forwards are the at most 2k2^k rising sequences. . That bound is looser than the exact Bayer-Diaconis result and needs nothing beyond the birthday calculation.

8 rising sequences

the ceiling after 3 shuffles is 8

8♣9♣Q♦A♠9♠2♠10♣K♦A♣8♥J♣3♥2♣9♥3♦4♥10♥3♣Q♣6♣4♦J♥K♣5♦Q♥4♣3♠10♠6♦J♠7♦4♠8♦5♠7♣6♠K♥Q♠5♣5♥9♦6♥K♠7♥10♦J♦7♠A♦8♠A♥2♦2♥
A deck sorted A to K in spades, hearts, diamonds, clubs, read from the top. Cards in the same rising sequence share a tint. Each shuffle brings another set of tints; past the seventh the count settles in the mid-twenties and further shuffles look alike.
uniform average08162432rising sequences012345678910shuffles
Rising sequences against shuffles. The dashed rule is the uniform average of 26.5: once the count reaches it, counting runs stops telling the two decks apart.

a uniformly random deck averages 26.5 (sd 2.10)

A uniformly random deck averages 26.5 runs with a standard deviation of 2.10, and the chance of 16 or fewer is 4.67×1074.67 \times 10^{-7}. A deck shuffled four times holds at most 16, so counting runs catches it, and the count is wrong about once in two million tries.

How to measure the distance from random

Counting runs is only one test among many. Take every test at once, including the ones nobody has thought of, and what comes out is the total variation distance: find the event whose probability differs most between the two distributions, and the size of that gap is

QmU=maxAQm(A)U(A)\|Q_m - U\| = \max_{A} |Q_m(A) - U(A)|

where QmQ_m is the distribution after mm shuffles and UU is uniform over the 52! arrangements. . Their example is a glimpse of the bottom card: the other 51 are genuinely random, and the distance is nonetheless 11/521 - 1/52.

The same quantity can be written as a wager. Two decks lie on the table, one shuffled mm times and one put in a genuinely random order by a computer, and you have to say which is which. Any method is allowed: count the rising sequences, turn over the top card and see whether the ace of spades is still there, look at the pattern of reds and blacks, spread all 52 out and compare at leisure. Blind guessing succeeds half the time, and the best method available succeeds with probability 12+12QmU\frac{1}{2} + \frac{1}{2}\|Q_m - U\|. That expression comes straight from the definition: take AA to be the event whose probability differs most, and call the deck shuffled whenever the outcome lands in AA.

Five shuffles give 96.2 percent, six give 80.7, seven give 66.7, eight 58.4, ten 52.1. The first four are all 100 percent, because counting runs already wins: four shuffles leave at most 16 runs, and a random deck produces 16 or fewer about once in two million.

Defined this way the distance covers tests nobody has invented yet. It takes a maximum rather than an average: in the bottom-card example almost every other event has barely moved, and the distance is near 1 all the same.

The exact numbers for 52 cards: 1.000 down to 0.043

. The arrangement enters the formula only through rr, so a sum over 52! terms collapses to 52 and the distance can be computed exactly.

deck size

after 7: distance 0.3341, told apart 66.7% of the time

1.5 log2 n = 8.550.000.250.500.751.00total variation distance2468101214number of shuffles
52 cards. Each point is the exact total variation distance to uniform after that many riffle shuffles. The dashed rule sits at 8.55, the position the asymptotic theory gives. The distance holds at 1, halves roughly once per shuffle past the rule, and never reaches 0. As a game: picking the shuffled deck out from a random one succeeds 50% of the time plus half the distance.

For 52 cards the first four shuffles all give 1.000, followed by 0.924, 0.614, 0.334, 0.167, 0.085 and 0.043. Here 32log252=8.55\frac{3}{2}\log_2 52 = 8.55. .

The numbers in the figure were recomputed here from the same formula in exact integer arithmetic: seven deck sizes, kk from 1 to 10, seventy values, all agreeing with Table 3 of the paper. Take the deck to 312 cards and the first seven shuffles are still 1.000, with 0.565 remaining at ten.

Said another way: cards guessed correctly

. Against a uniformly random deck the best strategy averages H52=1/52+1/51++1=4.54H_{52} = 1/52 + 1/51 + \cdots + 1 = 4.54 cards.

  • k shuffles
  • k shuffles then a cut
well-shuffled deck: 4.5446102040cards guessed correctly12345678910number of shuffles
Guess the cards one at a time, turning each over after the guess. The vertical axis is logarithmic. The dashed rule is the 4.54 expected against a uniformly random deck; five shuffles still leave two extra cards, six leave one, and each further shuffle roughly halves the excess.

Five shuffles leave 6.56 correct, two cards above a properly mixed deck; six leave 5.51, about one card above; after that the excess roughly halves each time.

. Passing a fixed battery of tests establishes only that those statistics look ordinary.

Caring only about colours takes fewer shuffles

Seven answers a question about the full arrangement of the deck. A blackjack player does not care whether the seven of spades precedes the seven of hearts, and a player betting on colour never looks at suits.

0.000.250.500.751.00separation distance123456789101112number of shuffles
One 52-card deck, one shuffling model, five questions. Click a legend entry to isolate a curve. Separation distance is defined differently from the total variation of the previous figure, so the two vertical axes do not compare; the five curves here do.

. Their distance is separation, so the numbers cannot be set beside the earlier figure, while the five curves within this one compare directly: the full order is still 0.278 away after twelve shuffles, blackjack values reach 0.366 by the ninth, and colour alone is at 0.317 by the sixth.

. They draw no recommendation from it. Their closing line is that which measure matters more to gamblers and card players is presumably game dependent.

Three questions to test yourself

Three questions, each built on a phrasing that circulates. Explanations follow the answers.

answered 0 / 3
  1. 1

    Which reading of “a 52-card deck needs seven shuffles” is the accurate one?

  2. 2

    Why does a deck shuffled four times or fewer fail even to look random?

  3. 3

    A casino supplier's engineers ran their own checks on a shuffling machine and saw nothing wrong; the three authors ruled it unusable. Where do the two standards differ?

Which statements hold, which are misreadings

The same result, in the phrasings that hold up and in the misreadings that keep coming back, each with the sentence that fixes it.

Said this way, it is right

Quoting the number together with its distance tells the reader what 0.334 means: no test can do better than a 33 percent edge.

Same deck, same distance, different question. "Random enough" is only meaningful once the use is named.

A conclusion reaches exactly as far as its model does. Whether hands match the model is an empirical question, separate from the theorem.

Said this way, it is wrong

The distance falls continuously from 1 towards 0 and never reaches it: 0.334 at seven, 0.043 at ten. Reading the steep part as a threshold turns a curve into a switch.

Write that mixing drops sharply between the fifth and eighth shuffle, and that the distance at seven is 0.334.

Seven belongs to 52 cards. The same formula gives five or six for 32 cards, eight or nine for 104, and eleven or more for 312, tracking (3/2) log2 n.

State the deck size first, then quote the number that goes with it.

Measured by information, 3.52 percent remains after five shuffles and 0.92 percent after six, with no cut-off at all. The paper closes by saying that which measure matters more to gamblers and card players is presumably game dependent. Change the distance and the answer changes.

Say "0.334 at seven under total variation; 3.52 percent of the information left at five and 0.92 percent at six", and keep the criterion inside the sentence.

Passing a fixed set of tests says only that those statistics look normal. The ten-shelf machine passed the engineers' own tests while letting a knowledgeable player guess 9.5 cards per run, against 4.5 for a well-shuffled deck.

Compute a distance, or a quantity that ranges over all tests such as the expected number of correct guesses under the best strategy.

What this piece does not claim

Every number above is computed under the Gilbert-Shannon-Reeds model. Whether real hands follow it is a separate question; the paper cites experiments reported by Diaconis in 1988, which this site has not examined. None of the tables applies to a deck with repeated cards, as when two decks are shuffled together or only part of one is dealt.

The guessing figures come from simulation, 100,000 runs per entry, under a strategy the paper describes as conjecturally optimal without proving it. In the separation table only the first row is exact; the rest come from an approximation, and the paper notes that the red-black row disagrees with the exact values 0.8898 and 0.8897 at one and two shuffles.

Nor is there advice here about how many times to shuffle. That question needs someone to say first what the deck is for, and whoever is using it decides that.