# Riffle Shuffle

The following is the Gilbert-Shannon-Reeds model of riffle shuffle introduced by Gilbert and Shannon in 1955 and independently by Reeds in 1985.

 Riffle Shuffle (Gilbert-Shannon 1955; Reeds 1985) Given a deck of ${\displaystyle n}$ cards, at each round, do as follows. Split the original deck into two decks according to the binomial distribution ${\displaystyle \mathrm {Bin} (n,1/2)}$. Cut off the first ${\displaystyle k}$ cards with probability ${\displaystyle {\frac {n \choose k}{2^{n}}}}$, put into the left deck, and put the rest ${\displaystyle n-k}$ cards into the right deck. Drop cards in sequence, where the next card comes from one of the two decks with probability proportional to the size of the deck at that time. Suppose at a step there are ${\displaystyle L}$ cards in the left deck and ${\displaystyle R}$ cards in the right deck. A card is dropped from left with probability ${\displaystyle {\frac {L}{L+R}}}$, and from right otherwise.

The second step actually samples a uniform interleaving of left and right deck. The magician and mathematician Diaconis in 1988 found evidence showing that this mathematical model reasonably approximate the riffle shuffling acted by human.

The above model is equivalent to the following model of inverse riffle shuffle.

 Inverse Riffle Shuffle Label each card with a bit from ${\displaystyle \{0,1\}}$ uniformly and independently at random. Place all cards labeled with 0 above all cards labeled with 1, keeping the cards with the same label in the same the relative order as before.

The process of inverse riffle shuffle is depicted as follows.

For each card, the random bits used for labeling the card compose a binary code ${\displaystyle x}$, with the ${\displaystyle t}$-th bit (from lower to higher radix) ${\displaystyle x_{t}}$ being the random bit chosen in round ${\displaystyle t}$ to label the card.

 Lemma After every round of the inverse riffle shuffle, the cards are sorted in non-decreasing order of their corresponding binary codes.
Proof.
 By induction. After the first round, all ${\displaystyle 0}$ are above all ${\displaystyle 1}$s. Assume that the hypothesis is true for the first ${\displaystyle t-1}$ rounds. After the ${\displaystyle t}$-th round, all cards with the highest coordinate ${\displaystyle x_{t}=0}$ are above all cards with ${\displaystyle x_{t}=1}$, and by the definition of inverse riffle shuffle, cards with the same highest bit ${\displaystyle x_{t}}$ are kept in the same relative order as they are after the ${\displaystyle (t-1)}$-th round of the shuffling, which due to the hypothesis, means that the cards with the same highest bit ${\displaystyle x_{t}}$ are sorted in the non-decreasing order of ${\displaystyle x_{t-1}x_{t-2}\cdots x_{1}}$. By the definition of binary representation, all cards are sorted.
${\displaystyle \square }$

# Rapid Mixing of Riffle Shuffle by Coupling

 Theorem The mixing time of inverse riffle shuffle of a deck of ${\displaystyle n}$ cards is ${\displaystyle \tau _{\mathrm {mix} }=O(\log n)}$.

Consider two instance of shuffling, started with two decks, each in an arbitrary order. We couple the two shuffling processes by coupling their random choices of labelings:

• In each round, we label the same cards (same content, not the same order) in the two decks with the same random bit.

Formally, for each ${\displaystyle i\in [n]}$, we uniformly and independently choose a random ${\displaystyle b_{i}\in \{0,1\}}$ as the label of the card ${\displaystyle i}$ in each of the two decks in that round. It is easy to see that, each of the two shuffling processes viewed individually follows exactly the rules of inverse riffle shuffle.

 Lemma With the above coupling rule, started with arbitrary two decks of cards, the two decks are the same once all cards in the first (or the second) deck have distinct labels.
Proof.
 By the definition of the coupling rule, any two identical cards in the two decks always have the same label, since in every round they choose the same random bit. And we have shown that after each round, the labels are sorted in non-decreasing order. Thus, we can conclude: after each round, the sequences of the labels of the two decks are identical (and sorted in non-decreasing order). Therefore, when all cards in the first deck have distinct labels, the second deck have the same set of distinct labels, and the cards are sorted increasingly in their labels in the respective decks. Since any two identical cards have the same labels, the cards in the two decks must be in the same order.
${\displaystyle \square }$

We denote by ${\displaystyle T}$ the random variable representing the time that in an inverse riffle shuffle, all cards in the deck have distinct labels. Due to the coupling lemma for Markov chains,

${\displaystyle \Delta (t)\leq \Pr[T\geq t]}$.

This bound can be deduced from the birthday problem. After ${\displaystyle t}$ round, each of the ${\displaystyle n}$ cards is randomly assigned one of the ${\displaystyle 2^{t}}$ possible labels. We know that for some ${\displaystyle 2^{t}=O(n^{2})}$, i.e. ${\displaystyle t=2\log n+O(1)}$, the probability that no two cards have the same label is ${\displaystyle >1-1/2\mathrm {e} }$, i.e. ${\displaystyle \Delta (t)<1/2\mathrm {e} }$, thus

${\displaystyle \tau _{\mathrm {mix} }\leq 2\log n+O(1)}$.

Note that the state space is the set of all permutations, which is of size ${\displaystyle n!}$, whose logarithm is still as large as ${\displaystyle \log(n!)=O(n\ln n)}$ due to Stirling's approximation. Thus the riffle shuffle is mixing extremely fast.

This estimation of mixing time is fairly tight. For the case that ${\displaystyle n=52}$, the real mixing rate is as follows.

 ${\displaystyle t}$ 1 2 3 4 5 6 7 8 9 ${\displaystyle \Delta (t)}$ 1 1 1 1 0.924 0.614 0.334 0.167 0.003