therandomhomepage

A hand-kept directory of curious corners of the web, and notes on how chance works.

Top › Machines

Shuffling a Deck Properly, by Hand and by Computer

A shuffle is a random number generator made of cardboard. Done badly, by hand or in code, it leaves patterns that a careful observer can exploit.

What a shuffle is for

Shuffling is meant to put a deck into an order that nobody can predict, with every possible order equally likely. Card games are fair only if that holds.

Hand shuffles

  • Overhand shuffle. Small packets moved from one hand to the other. Easy, but it mixes slowly.
  • Riffle shuffle. The deck is split in two and the halves interleaved. It mixes faster, and is the usual choice for card games.
  • Wash or smoosh. Cards spread face down on the table and stirred. Messy, and good at breaking up order.

A single shuffle of any kind leaves much of the previous order intact. Several riffles in a row mix far better than one.

The computer version

The standard algorithm is the Fisher–Yates shuffle. Working from the end of the list, each card is swapped with a card chosen at random from the positions not yet fixed. Done correctly, every order is equally likely.

A classic bug

A tempting shortcut is to swap each card with any position in the whole deck. It looks equivalent and is not: some orders come up more often than others. Small biases like this are invisible in a few deals and obvious over many.

The generator still matters

Even a perfect algorithm is only as good as its random numbers. See how random number generators work.

filed 2026-10-22