A riffle shuffle is a shuffle in which a deck is divided into two packets whose cards are interleaved while preserving their original order
within each packet. A perfect riffle shuffle, also called a Faro shuffle, divides
a deck of
cards into equal halves and interleaves their cards in strict
alternation. An in-shuffle takes the first card from
the bottom half. An out-shuffle
takes it from the top half. Using an in-shuffle,
a deck originally arranged from top to bottom as 1 2 3 4 5 6 7 8 would become 5 1
6 2 7 3 8 4. Using an out-shuffle, the deck order
would become 1 5 2 6 3 7 4 8. Riffle shuffles are used in card tricks (Marlo 1958ab,
Adler 1973), and also in the theory of parallel processing (Stone 1971, Chen et
al. 1981).
For a positive even number of cards, an
out-shuffle is implemented in the Wolfram
Language using Riffle,
for example:
Riffle @@ Partition[Range[n], n/2, n/2, 1, {}]
For an in-shuffle of cards, number the positions from 1 through
. The card at position
moves to position
modulo
. For an out-shuffle,
number the positions from 0 through
. The first and last cards
remain fixed, and each interior card moves from position
to position
modulo
.
Therefore, in-shuffling an even number cards
times when
is prime results in the original card order. Similarly,
out-shuffling an even number
cards
times when
is prime results in the original order (Diaconis et al.
1983, Conway and Guy 1996). An ordinary deck of 52 cards is returned to its original
order after 52 in-shuffles, but after only eight out-shuffles!
In the Gilbert-Shannon-Reeds model, for a deck of cards, the first packet size has a binomial
distribution with parameters
and
. Given the cut, each interleaving
that preserves the order within the packets has equal probability.
For independent shuffles in this model,
Aldous (1983, p. 266) showed that the mixing time
at any fixed total variation distance
threshold strictly between 0 and 1 is asymptotic to
as
. Aldous and Diaconis (1986, p. 345)
suggested seven riffle shuffles to get close to random for a deck of 52 cards.
For this deck size, Bayer and Diaconis (1992, p. 296) give total
variation distance from the uniform distribution
of approximately 0.334 after seven shuffles, 0.167 after eight, and 0.085 after nine.
Morris (1994) discusses aspects of the perfect riffle shuffle (in which the deck is cut exactly in half and cards are perfectly interlaced). Ramnath and Scully (1996)
give an algorithm for the shortest sequence of in- and out-shuffles to move a card
from arbitrary position
to position
. This algorithm works for any deck with an even
number of cards and is
.