GenerateRandomSearch

Riffle Shuffle Calculator

Seven shuffles is the usual answer for a pack of fifty-two, and it is not folklore — it is a measured result. Bayer and Diaconis showed that a riffle shuffle mixes hardly at all for the first few repetitions and then collapses to nearly uniform over two or three more. This computes that curve for any deck size, so you can see both the cliff and where your deck sits on it.

What this generator does

Applies the Bayer-Diaconis result for the total variation distance after a given number of riffle shuffles, tabulates it for each shuffle count, and reports the first count where the distance falls below the usual cutoff of one half.

How to use this tool

  1. Enter how many cards are in the deck.
  2. Choose how many shuffles to tabulate.
  3. Press Solve.
  4. Read the distance from uniform after each riffle, and where it crosses the usual cutoff.

Understanding the controls

Cards in the deck
Fifty-two for a standard pack. Two packs shuffled together is 104, and some card games use several hundred — the shuffles needed grows only with the logarithm of that.
Shuffles to tabulate
How many riffles to show. Twelve is enough to see the whole collapse for a standard deck; a very large deck needs a few more.

Common use cases

  • Settling how many shuffles a card game actually needs
  • Explaining why three shuffles leaves a deck badly mixed
  • Working out the shuffles needed for a double deck or a game with 200 cards
  • Understanding the cutoff phenomenon with a familiar example
  • Deciding whether a shuffling machine's setting is enough

How this generator works

Bayer and Diaconis showed that after a number of riffles equal to one and a half times the base-two logarithm of the deck size, plus some offset, the total variation distance from a uniform deck follows a fixed curve in that offset alone. The tool evaluates that curve for each shuffle count. Distance here is total variation: the largest error you could make in any statement about the deck. Before display every distance is checked to lie between nought and one, confirmed never to rise as shuffles are added, and the reported threshold is found again by scanning the finished table.

Randomness and fairness

Nothing here is random. This computes how well a shuffle mixes rather than shuffling anything — the card and shuffle generators are the ones that produce an actual order.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • This models the Gilbert-Shannon-Reeds riffle, which describes a reasonably good human shuffle. A sloppy or clumped riffle mixes more slowly than this.
  • Total variation is a demanding standard. Most card games do not need the deck mixed that well, and a few card tricks survive far more shuffles than this suggests.
  • Overhand shuffling is a different and much slower process, needing thousands of repetitions rather than a handful.
  • The formula is an asymptotic result, so it is at its least exact for very small decks.

Privacy and your data

The calculation runs in your browser. Only the deck size is entered, and it is never transmitted, stored or included in analytics.