Skip to the interactive
ExplainerTools Watch the 35-second film

Probability · interactive

How many riffles mix a deck?

Model · ideal riffles

Each card’s color is its place in the fresh deck. Threads join cards still in their original order; the lit thread holds the close-up card. Bottom left: this one sample deck. Bottom right: every possible deck, computed exactly.

1 See

A fresh deck runs 1 to 52, top to bottom. A riffle cuts it in two and lets the halves fall together. How many riffles until the original order stops showing?

2 Change

3 Understand

Watch the 35-second film
Model notes and sources

Ideal Gilbert–Shannon–Reeds (GSR) riffles of 52 distinct cards, as described by Bayer and Diaconis. Each riffle cuts the deck after k cards with probability C(52, k)/252. Cards then fall one at a time from the bottom of either half, with probability proportional to the cards left in that half. Every compatible cut and interleaving has probability 2−52. Both halves keep their order, and every card keeps its identity.

Convention: deck[position] = card, position 1 = top; a card’s number is its place in the fresh deck. With pos[card] = position, the number of rising sequences is r = 1 + descents(pos): runs of consecutive card numbers still in their original order (the threads). It is not the number of increasing stretches you read along the spread. One riffle leaves r ≤ 2; m riffles leave r ≤ 2m.

The chance of one exact order after m riffles is Pm(π) = C(2m + 52 − r, 52) / 252m. That is the mass on a single order, not a distance. A perfectly mixed deck gives every order 1 in 52! ≈ 8.07 × 1067. The distance from uniform is the total variation distance of the whole distribution, d = ½ Σπ |Pm(π) − 1/52!|. It is computed exactly by grouping all 52! orders by r with Eulerian numbers, in double precision (error estimated below 10−12), with no sampling. Bayer and Diaconis report 0.614 after six riffles and 0.334 after seven; the bars use the same formula.

The sample deck is one seeded realization (mulberry32 generator, seed shown), replayed riffle by riffle from the same stream. It is not a frequency estimate: its rising-sequence count can fall as well as rise, and no single deck measures the distance. The 0.5 yardstick is a convention for ‘close enough’ in this ideal model. Seven is not perfect randomness, and other yardsticks or measures of mixing give other counts. Not modeled: real hands (clumpy drops, uneven cuts), overhand shuffles, casino machines, and repeated or marked cards. Domain: 52 cards, 0–10 riffles. Animation timing is for viewing, not the speed of a real shuffle.

Source: D. Bayer and P. Diaconis, Trailing the Dovetail Shuffle to Its Lair, Annals of Applied Probability 2 (1992), §§1–3. The paper credits the riffle model to Gilbert, Shannon and Reeds.

An ExplainerTools Original. Concept inspired by Dave Bayer and Persi Diaconis’s Trailing the Dovetail Shuffle to Its Lair.

Keep exploring

Up next

  1. Interactive · MathKeep squaring and adding. Does it escape?
  2. Interactive · MathHow much can compound interest really grow?
  3. Interactive · MathWhy do sunflower seeds form spirals?