# Mixing Time

The mixing time of a Markov chain gives the rate at which a Markov chain converges to the stationary distribution. To rigorously define this notion, we need a way of measuring the closeness between two distributions.

## Total Variation Distance

In probability theory, the total variation distance measures the difference between two probability distributions.

 Definition (total variation distance) Let ${\displaystyle p}$ and ${\displaystyle q}$ be two probability distributions over the same finite state space ${\displaystyle \Omega }$, the total variation distance between ${\displaystyle p}$ and ${\displaystyle q}$ is defined as ${\displaystyle \|p-q\|_{TV}={\frac {1}{2}}\sum _{x\in \Omega }|p(x)-q(x)|={\frac {1}{2}}\|p-q\|_{1}}$, where ${\displaystyle \|\cdot \|_{1}}$ is the ${\displaystyle \ell _{1}}$-norm of vectors.

It can be verified (left as an exercise) that

${\displaystyle \max _{A\subset \Omega }|p(A)-q(A)|={\frac {1}{2}}\sum _{x\in \Omega }|p(x)-q(x)|}$,

thus the total variation distance can be equivalently defined as

${\displaystyle \|p-q\|_{TV}=\max _{A\subset \Omega }|p(A)-q(A)|}$.

So the total variation distance between two distributions gives an upper bound on the difference between the probabilities of the same event according to the two distributions.

## Mixing Time

 Definition (mixing time) Let ${\displaystyle \pi }$ be the stationary of the chain, and ${\displaystyle p_{x}^{(t)}}$ be the distribution after ${\displaystyle t}$ steps when the initial state is ${\displaystyle x}$. ${\displaystyle \Delta _{x}(t)=\|p_{x}^{(t)}-\pi \|_{TV}}$ is the distance to stationary distribution ${\displaystyle \pi }$ after ${\displaystyle t}$ steps, started at state ${\displaystyle x}$. ${\displaystyle \Delta (t)=\max _{x\in \Omega }\Delta _{x}(t)}$ is the maximum distance to stationary distribution ${\displaystyle \pi }$ after ${\displaystyle t}$ steps. ${\displaystyle \tau _{x}(\epsilon )=\min\{t\mid \Delta _{x}(t)\leq \epsilon \}}$ is the time until the total variation distance to the stationary distribution, started at the initial state ${\displaystyle x}$, reaches ${\displaystyle \epsilon }$. ${\displaystyle \tau (\epsilon )=\max _{x\in \Omega }\tau _{x}(\epsilon )}$ is the time until the total variation distance to the stationary distribution, started at the worst possible initial state, reaches ${\displaystyle \epsilon }$.

We note that ${\displaystyle \Delta _{x}(t)}$ is monotonically non-increasing in ${\displaystyle t}$. So the definition of ${\displaystyle \tau _{x}(\epsilon )}$ makes sense, and is actually the inverse of ${\displaystyle \Delta _{x}(t)}$.

 Definition (mixing time) The mixing time ${\displaystyle \tau _{\mathrm {mix} }}$ of a Markov chain is ${\displaystyle \tau (1/2\mathrm {e} )}$.

The mixing time is the time until the total variation distance to the stationary distribution, starting from the worst possible initial state ${\displaystyle x\in \Omega }$, reaches ${\displaystyle {\frac {1}{2\mathrm {e} }}}$. The value ${\displaystyle {\frac {1}{2\mathrm {e} }}}$ is chosen just for the convenience of calculation. The next proposition says that ${\displaystyle \tau (\epsilon )}$ with general ${\displaystyle \epsilon }$ can be estimated from ${\displaystyle \tau _{\mathrm {mix} }}$.

 Proposition ${\displaystyle \Delta (k\cdot \tau _{\mathrm {mix} })\leq \mathrm {e} ^{-k}}$ for any integer ${\displaystyle k\geq 1}$. ${\displaystyle \tau (\epsilon )\leq \tau _{\mathrm {mix} }\cdot \left\lceil \ln {\frac {1}{\epsilon }}\right\rceil }$.

So the distance to stationary distribution ${\displaystyle \Delta (t)}$ decays exponentially in multiplications of ${\displaystyle \tau _{\mathrm {mix} }}$.

Both the formal proofs of the monotonicity of ${\displaystyle \Delta _{x}(t)}$ and the above proposition uses the coupling technique and is postponed to next section.

# Coupling

We will discuss how to bound the mixing time by coupling two Markov chains. Before that, we will first formally introduce the coupling of two probability distributions.

## Coupling of Two Distributions

Coupling is a powerful proof technique in probability theory. It allows us to compare two unrelated variables (or processes) by forcing them to share some randomness.

 Definition (coupling) Let ${\displaystyle p}$ and ${\displaystyle q}$ be two probability distributions over ${\displaystyle \Omega }$. A probability distribution ${\displaystyle \mu }$ over ${\displaystyle \Omega \times \Omega }$ is said to be a coupling if its marginal distributions are ${\displaystyle p}$ and ${\displaystyle q}$; that is {\displaystyle {\begin{aligned}p(x)&=\sum _{y\in \Omega }\mu (x,y);\\q(x)&=\sum _{y\in \Omega }\mu (y,x).\end{aligned}}}

The interesting case is when ${\displaystyle X}$ and ${\displaystyle Y}$ are not independent. In particular, we want the probability that ${\displaystyle X=Y}$ to be as large as possible, yet still maintaining the respective marginal distributions ${\displaystyle p}$ and ${\displaystyle q}$. When ${\displaystyle p}$ and ${\displaystyle q}$ are different it is inevitable that ${\displaystyle X\neq Y}$ with some probability, but how small this probability can be, that is, how well two distributions can be coupled? The following coupling lemma states that this is determined by the total variation distance between the two distributions.

 Lemma (coupling lemma) Let ${\displaystyle p}$ and ${\displaystyle q}$ be two probability distributions over ${\displaystyle \Omega }$. For any coupling ${\displaystyle (X,Y)}$ of ${\displaystyle p}$ and ${\displaystyle q}$, it holds that ${\displaystyle \Pr[X\neq Y]\geq \|p-q\|_{TV}}$. There exists a coupling ${\displaystyle (X,Y)}$ of ${\displaystyle p}$ and ${\displaystyle q}$ such that ${\displaystyle \Pr[X\neq Y]=\|p-q\|_{TV}}$.
Proof.
 1. Suppose ${\displaystyle (X,Y)}$ follows the distribution ${\displaystyle \mu }$ over ${\displaystyle \Omega \times \Omega }$. Due to the definition of coupling, {\displaystyle {\begin{aligned}p(x)=\sum _{y\in \Omega }\mu (x,y)&\quad {\text{and }}&q(x)=\sum _{y\in \Omega }\mu (y,x).\end{aligned}}} Then for any ${\displaystyle z\in \Omega }$, ${\displaystyle \mu (z,z)\leq \min\{p(z),q(z)\}}$, thus {\displaystyle {\begin{aligned}\Pr[X=Y]&=\sum _{z\in \Omega }\mu (z,z)\leq \sum _{z\in \Omega }\min\{p(z),q(z)\}.\end{aligned}}} Therefore, {\displaystyle {\begin{aligned}\Pr[X\neq Y]&\geq 1-\sum _{z\in \Omega }\min\{p(z),q(z)\}\\&=\sum _{z\in \Omega }(p(z)-\min\{p(z),q(z)\})\\&=\sum _{z\in \Omega \atop p(z)>q(z)}(p(z)-q(z))\\&={\frac {1}{2}}\sum _{z\in \Omega }|p(z)-q(z)|\\&=\|p-q\|_{TV}.\end{aligned}}} 2. We can couple ${\displaystyle X}$ and ${\displaystyle Y}$ so that for each ${\displaystyle z\in \Omega }$, ${\displaystyle X=Y=z}$ with probability ${\displaystyle \min\{p(z),q(z)\}}$. The remaining follows as above.
${\displaystyle \square }$

The proof is depicted by the following figure, where the curves are the probability density functions for the two distributions ${\displaystyle p}$ and ${\displaystyle q}$, the colored area is the diference between the two distribution, and the "lower envelope" (the red line) is the ${\displaystyle \min\{p(x),q(x)\}}$.

### Monotonicity of ${\displaystyle \Delta _{x}(t)}$

Consider a Markov chain on state space ${\displaystyle \Omega }$. Let ${\displaystyle \pi }$ be the stationary distribution, and ${\displaystyle p_{x}^{(t)}}$ be the distribution after ${\displaystyle t}$ steps when the initial state is ${\displaystyle x}$. Recall that ${\displaystyle \Delta _{x}(t)=\|p_{x}^{(t)}-\pi \|_{TV}}$ is the distance to stationary distribution ${\displaystyle \pi }$ after ${\displaystyle t}$ steps, started at state ${\displaystyle x}$.

We will show that ${\displaystyle \Delta _{x}(t)}$ is non-decreasing in ${\displaystyle t}$. That is, for a Markov chain, the variation distance to the stationary distribution monotonically decreases as time passes. Although this is rather intuitive at the first glance, the proof is nontrivial. A brute force (algebraic) proof can be obtained by analyze the change to the 1-norm of ${\displaystyle p_{x}^{(t)}-\pi }$ by multiplying the transition matrix ${\displaystyle P}$. The analysis uses eigen decomposition. We introduce a cleverer proof using coupling.

 Proposition ${\displaystyle \Delta _{x}(t)}$ is non-decreasing in ${\displaystyle t}$.
Proof.
 Let ${\displaystyle X_{0}=x}$ and ${\displaystyle Y_{0}}$ follow the stationary distribution ${\displaystyle \pi }$. Two chains ${\displaystyle X_{0},X_{1},X_{2},\ldots }$ and ${\displaystyle Y_{0},Y_{1},Y_{2},\ldots }$ can be defined by the initial distributions ${\displaystyle X_{0}}$ and ${\displaystyle Y_{0}}$. The distributions of ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$ are ${\displaystyle p_{x}^{(t)}}$ and ${\displaystyle \pi }$, respectively. For any fixed ${\displaystyle t}$, we can couple ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$ such that ${\displaystyle \Pr[X_{t}\neq Y_{t}]=\|p_{x}^{(t)}-\pi \|_{TV}=\Delta _{x}(t)}$. Due to the Coupling Lemma, such coupling exists. We then define a coupling between ${\displaystyle X_{t+1}}$ and ${\displaystyle Y_{t+1}}$ as follows. If ${\displaystyle X_{t}=Y_{t}}$, then ${\displaystyle X_{t+1}=Y_{t+1}}$ following the transition matrix of the Markov chain. Otherwise, do the transitions ${\displaystyle X_{t}\rightarrow X_{t+1}}$ and ${\displaystyle Y_{t}\rightarrow Y_{t+1}}$ independently, following the transitin matrix. It is easy to see that the marginal distributions of ${\displaystyle X_{t+1}}$ and ${\displaystyle Y_{t+1}}$ both follow the original Markov chain, and ${\displaystyle \Pr[X_{t+1}\neq Y_{t+1}]\leq \Pr[X_{t}\neq Y_{t}].}$ In conclusion, it holds that ${\displaystyle \Delta _{x}(t+1)=\|p_{x}^{(t+1)}-\pi \|_{TV}\leq \Pr[X_{t+1}\neq Y_{t+1}]\leq \Pr[X_{t}\neq Y_{t}]=\Delta _{x}(t),}$ where the first inequality is due to the easy direction of the Coupling Lemma.
${\displaystyle \square }$

## Rapid Mixing by Coupling

Consider an ergodic (irreducible and aperiodic) Markov chain on finite state space ${\displaystyle \Omega }$. We want to upper bound its mixing time. The coupling technique for bounding the mixing time can be sumerized as follows:

Consider two random walks starting at state ${\displaystyle x}$ and ${\displaystyle y}$ in ${\displaystyle \Omega }$. Each individual walk follows the transition rule of the original Markov chain. But the two random walks may be "coupled" in some way, that is, may be correlated with each other. A key observation is that for any such coupling, it always holds that
${\displaystyle \Delta (t)\leq \max _{x,y\in \Omega }\Pr[{\text{ the two }}{\mathit {coupled}}{\text{ random walks started at }}x,y{\text{ have not met by time }}t]}$
where we recall that ${\displaystyle \Delta (t)=\max _{x\in \Omega }\|p_{x}^{(t)}-\pi \|_{TV}}$.
 Definition (coupling of Markov chain) A coupling of a Markov chain with state space ${\displaystyle \Omega }$ and transition matrix ${\displaystyle P}$, is a Markov chain ${\displaystyle (X_{t},Y_{t})}$ with state space ${\displaystyle \Omega \times \Omega }$, satisfying each of ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$ viewed in isolation is a faithful copy of the original Markov chain, i.e. ${\displaystyle \Pr[X_{t+1}=v\mid X_{t}=u]=\Pr[Y_{t+1}=v\mid Y_{t}=u]=P(u,v)}$; once ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$ reaches the same state, they make identical moves ever since, i.e. ${\displaystyle X_{t+1}=Y_{t+1}}$ if ${\displaystyle X_{t}=Y_{t}}$.
 Lemma (coupling lemma for Markov chains) Let ${\displaystyle (X_{t},Y_{t})}$ be a coupling of a Markov chain ${\displaystyle M}$ with state space ${\displaystyle \Omega }$. Then ${\displaystyle \Delta (t)}$ for ${\displaystyle M}$ is bounded by ${\displaystyle \Delta (t)\leq \max _{x,y\in \Omega }\Pr[X_{t}\neq Y_{t}\mid X_{0}=x,Y_{0}=y]}$.
Proof.
 Due to the coupling lemma (for probability distributions), ${\displaystyle \Pr[X_{t}\neq Y_{t}\mid X_{0}=x,Y_{0}=y]\geq \|p_{x}^{(t)}-p_{y}^{(t)}\|_{TV},}$ where ${\displaystyle p_{x}^{(t)},p_{y}^{(t)}}$ are distributions of the Markov chain ${\displaystyle M}$ at time ${\displaystyle t}$, started at states ${\displaystyle x,y}$. Therefore, {\displaystyle {\begin{aligned}\Delta (t)&=\max _{x\in \Omega }\|p_{x}^{(t)}-\pi \|_{TV}\\&\leq \max _{x,y\in \Omega }\|p_{x}^{(t)}-p_{y}^{(t)}\|_{TV}\\&\leq \max _{x,y\in \Omega }\Pr[X_{t}\neq Y_{t}\mid X_{0}=x,Y_{0}=y].\end{aligned}}}
${\displaystyle \square }$

 Corollary Let ${\displaystyle (X_{t},Y_{t})}$ be a coupling of a Markov chain ${\displaystyle M}$ with state space ${\displaystyle \Omega }$. Then ${\displaystyle \tau (\epsilon )}$ for ${\displaystyle M}$ is bounded as follows: ${\displaystyle \max _{x,y\in \Omega }\Pr[X_{t}\neq Y_{t}\mid X_{0}=x,Y_{0}=y]\leq \epsilon \quad \Longrightarrow \quad \tau (\epsilon )\leq t}$.

### Geometric convergence

Consider a Markov chain on state space ${\displaystyle \Omega }$. Let ${\displaystyle \pi }$ be the stationary distribution, and ${\displaystyle p_{x}^{(t)}}$ be the distribution after ${\displaystyle t}$ steps when the initial state is ${\displaystyle x}$. Recall that

• ${\displaystyle \Delta _{x}(t)=\|p_{x}^{(t)}-\pi \|_{TV}}$;
• ${\displaystyle \Delta (t)=\max _{x\in \Omega }\Delta _{x}(t)}$;
• ${\displaystyle \tau _{x}(\epsilon )=\min\{t\mid \Delta _{x}(t)\leq \epsilon \}}$;
• ${\displaystyle \tau (\epsilon )=\max _{x\in \Omega }\tau _{x}(\epsilon )}$;
• ${\displaystyle \tau _{\mathrm {mix} }=\tau (1/2\mathrm {e} )\,}$.

We prove that

 Proposition ${\displaystyle \Delta (k\cdot \tau _{\mathrm {mix} })\leq \mathrm {e} ^{-k}}$ for any integer ${\displaystyle k\geq 1}$. ${\displaystyle \tau (\epsilon )\leq \tau _{\mathrm {mix} }\cdot \left\lceil \ln {\frac {1}{\epsilon }}\right\rceil }$.
Proof.
 1. We denote that ${\displaystyle \tau =\tau _{\mathrm {mix} }\,}$. We construct a coupling of the Markov chain as follows. Suppose ${\displaystyle t=k\tau }$ for some integer ${\displaystyle k}$. If ${\displaystyle X_{t}=Y_{t}}$ then ${\displaystyle X_{t+i}=Y_{t+i}}$ for ${\displaystyle i=1,2,\ldots ,\tau }$. For the case that ${\displaystyle X_{t}=u,Y_{t}=v}$ for some ${\displaystyle u\neq v}$, we couple the ${\displaystyle X_{t+\tau }}$ and ${\displaystyle Y_{t+\tau }}$ so that ${\displaystyle \Pr[X_{t+\tau }\neq Y_{t+\tau }\mid X_{t}=u,Y_{t}=v]=\|p_{u}^{(t)}-p_{v}^{(t)}\|_{TV}}$. Due to the Coupling Lemma, such coupling does exist. For any ${\displaystyle u,v\in \Omega }$ that ${\displaystyle u\neq v}$, {\displaystyle {\begin{aligned}\Pr[X_{t+\tau }\neq Y_{t+\tau }\mid X_{t}=u,Y_{t}=v]&=\|p_{u}^{(\tau )}-p_{v}^{(\tau )}\|_{TV}\\&\leq \|p_{u}^{(\tau )}-\pi \|_{TV}+\|p_{v}^{(\tau )}-\pi \|_{TV}\\&=\Delta _{u}(\tau )+\Delta _{v}(\tau )\\&\leq {\frac {1}{\mathrm {e} }}.\end{aligned}}} Thus ${\displaystyle \Pr[X_{t+\tau }\neq Y_{t+\tau }\mid X_{t}\neq Y_{t}]\leq {\frac {1}{\mathrm {e} }}}$ by the law of total probability. Therefore, for any ${\displaystyle x,y\in \Omega }$, {\displaystyle {\begin{aligned}&\quad \,\Pr[X_{t+\tau }\neq Y_{t+\tau }\mid X_{0}=x,Y_{0}=y]\\&=\Pr[X_{t+\tau }\neq Y_{t+\tau }\mid X_{t}\neq Y_{t}]\cdot \Pr[X_{t}\neq Y_{t}\mid X_{0}=x,Y_{0}=y]\\&\leq {\frac {1}{\mathrm {e} }}\Pr[X_{t}\neq Y_{t}\mid X_{0}=x,Y_{0}=y].\end{aligned}}} Then by induction, ${\displaystyle \Pr[X_{k\tau }\neq Y_{k\tau }\mid X_{0}=x,Y_{0}=y]\leq \mathrm {e} ^{-k},}$ and this holds for any ${\displaystyle x,y\in \Omega }$. By the Coupling Lemma for Markov chains, this means ${\displaystyle \Delta (k\tau _{\mathrm {mix} })=\Delta (k\tau )\leq \mathrm {e} ^{-k}}$. 2. By the definition of ${\displaystyle \tau (\epsilon )}$, the inequality is straightforwardly implied by (1).
${\displaystyle \square }$

## Application: Random Walk on the Hypercube

A ${\displaystyle n}$-dimensional hypercube is a graph on vertex set ${\displaystyle \{0,1\}^{n}}$. For any ${\displaystyle x,y\in \{0,1\}^{n}}$, there is an edge between ${\displaystyle x}$ and ${\displaystyle y}$ if ${\displaystyle x}$ and ${\displaystyle y}$ differ at exact one coordinate (the hamming distance between ${\displaystyle x}$ and ${\displaystyle y}$ is 1).

We use coupling to bound the mixing time of the following simple random walk on a hypercube.

 Random Walk on Hypercube At each step, for the current state ${\displaystyle x\in \{0,1\}^{n}}$: with probability ${\displaystyle 1/2}$, do nothing; else, pick a coordinate ${\displaystyle i\in \{1,2,\ldots ,n\}}$ uniformly at random and flip the bit ${\displaystyle x_{i}}$ (change ${\displaystyle x_{i}}$ to ${\displaystyle 1-x_{i}}$).

This is a lazy uniform random walk in an ${\displaystyle n}$-dimensional hypercube. It is equivalent to the following random walk.

 Random Walk on Hypercube At each step, for the current state ${\displaystyle x\in \{0,1\}^{n}}$: pick a coordinate ${\displaystyle i\in \{1,2,\ldots ,n\}}$ uniformly at random and a bit ${\displaystyle b\in \{0,1\}}$ uniformly at random; let ${\displaystyle x_{i}=b}$.

It is easy to see the two random walks are the same. The second form hint us to couple the random choice of ${\displaystyle i}$ and ${\displaystyle b}$ in each step. Consider two copies of the random walk ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$, started from arbitrary two states ${\displaystyle X_{0}}$ and ${\displaystyle Y_{0}}$, the coupling rule is:

• At each step, ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$ choose the same (uniformly random) coordinate ${\displaystyle i}$ and the same (uniformly random) bit ${\displaystyle b}$.

Obviously the two individual random walks are both faithful copies of the original walk.

For arbitrary ${\displaystyle x,y\in \{0,1\}^{n}}$, started at ${\displaystyle X_{0}=x,Y_{0}=y}$, the event ${\displaystyle X_{t}=Y_{t}}$ occurs if everyone of the coordinates on which ${\displaystyle x}$ and ${\displaystyle y}$ disagree has been picked at least once. In the worst case, ${\displaystyle x}$ and ${\displaystyle y}$ disagree on all ${\displaystyle n}$ coordinates. The time ${\displaystyle T}$ that all ${\displaystyle n}$ coordinates have been picked follows the coupon collector problem collecting ${\displaystyle n}$ coupons, and we know from the coupon collector problem that for ${\displaystyle c>0}$,

${\displaystyle \Pr[T\geq n\ln n+cn]\leq \mathrm {e} ^{-c}.}$

Thus for any ${\displaystyle x,y\in \{0,1\}^{n}}$, if ${\displaystyle t\geq n\ln n+cn}$, then ${\displaystyle \Pr[X_{t}\neq Y_{t}\mid X_{0}=x,Y_{0}=y]\leq \mathrm {e} ^{-c}}$. Due to the coupling lemma for Markov chains,

${\displaystyle \Delta (n\ln n+cn)\leq \mathrm {e} ^{-c},}$

which implies that

${\displaystyle \tau (\epsilon )=n\ln n+n\ln {\frac {1}{\epsilon }}}$.

So the random walk achieves a polynomially small variation distance ${\displaystyle \epsilon ={\frac {1}{\mathrm {poly} (n)}}}$ to the stationary distribution in time ${\displaystyle O(n\ln n)}$.

Note that the number of states (vertices in the ${\displaystyle n}$-dimensional hypercube) is ${\displaystyle 2^{n}}$. Therefore, the mixing time is exponentially small compared to the size of the state space.

# Card Shuffling

We consider the Markov chain of shuffling a deck of cards, and prove the rapid mixing of the chain by coupling.

## 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

# Graph Colorings

A proper coloring of a graph ${\displaystyle G(V,E)}$ is a mapping ${\displaystyle f:V\rightarrow [q]}$ for some integer ${\displaystyle q}$, satisfying that ${\displaystyle f(u)\neq f(v)}$ for all ${\displaystyle uv\in E}$.

We consider the problem of sampling a uniformly random proper coloring of a given graph. We will later see that this is useful for counting the number of proper colorings of a given graph, which is a fundamental combinatorial problem, having important applications in statistic physics.

Let's first consider the decision version of the problem. That is, given as input a graph ${\displaystyle G(V,E)}$, decide whether there exists a proper ${\displaystyle q}$-coloring of ${\displaystyle G}$. Denote by ${\displaystyle \Delta }$ the maximum degree of ${\displaystyle G}$.

• If ${\displaystyle q\geq \Delta +1}$, there always exists a proper coloring. Moreover, the proper coloring can be found by a simple greedy algorithm.
• If ${\displaystyle q=\Delta }$, ${\displaystyle G}$ has a proper coloring unless it contains a ${\displaystyle (\Delta +1)}$-clique or it is an odd cycle. (Brooks Theorem)
• If ${\displaystyle q<\Delta }$, the problem is NP-hard.

Sampling a random coloring is at least as hard as deciding its existence, so we don't expect to solve the sampling problem when ${\displaystyle q<\Delta }$. The decision problem for the case ${\displaystyle q=\Delta }$ is also nontrivial. Thus people are interested only in the case when ${\displaystyle q\geq \Delta +1}$.

The following is a natural Markov chain for sampling proper colorings.

 Markov Chain for Graph Coloring ${\displaystyle {\mathcal {M}}_{c}}$ Start with a proper coloring of ${\displaystyle G(V,E)}$. At each step: Pick a vertex ${\displaystyle v\in V}$ and a color ${\displaystyle c\in [q]}$ uniformly at random. Change the color of ${\displaystyle v}$ to ${\displaystyle c}$ if the resulting coloring is proper; do nothing if otherwise.

For a fixed graph ${\displaystyle G(V,E)}$, the state space of the above Markov chain is the set of all proper colorings of ${\displaystyle G}$ with ${\displaystyle q}$ colors.

 Lemma The followings hold for ${\displaystyle {\mathcal {M}}_{c}}$. Aperiodic. The transition matrix is symmetric. Irreducible if ${\displaystyle q\geq \Delta +2}$.

The followings are the two most important conjectures regarding the problem.

 Conjecture ${\displaystyle {\mathcal {M}}_{c}}$ has mixing time ${\displaystyle O(n\ln n)}$ whenever ${\displaystyle q\geq \Delta +2}$. Random sampling of proper graph colorings can be done in polynomial time whenever ${\displaystyle q\geq \Delta +1}$.

These two conjectures are still open. People approach them by relax the requirement for the number of colors ${\displaystyle q}$. Intuitively, the larger the ${\displaystyle q}$ is, the more freedom we have, the less dependency are there between non-adjacent vertices.

## Rapid mixing of the case ${\displaystyle q>4\Delta }$

We couple the two copies of ${\displaystyle {\mathcal {M}}_{c}}$, ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$, by the following coupling rule:

• At each step, let ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$ choose the same vertex ${\displaystyle v}$ and same color ${\displaystyle c}$.

Note that by this coupling, it is possible that ${\displaystyle v}$ is recolored to ${\displaystyle c}$ in both chains, in one of the two chains, or in no chain. We may separate these cases by looking at the Hamming distance between two colorings.

Let ${\displaystyle d(X_{t},Y_{t})}$ be the number of vertices whose colors in ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$ disagree. For each step, for any choice of vertex ${\displaystyle v}$ and color ${\displaystyle c}$, there are three possible cases:

• "Good move" (${\displaystyle d(X_{t},Y_{t})}$ decreases by 1): ${\displaystyle X_{t}}$ disagree with ${\displaystyle Y_{t}}$ at ${\displaystyle v}$, and ${\displaystyle c}$ is not used in the colors of ${\displaystyle v}$ in both ${\displaystyle X_{t}}$ and ${\displaystyle Y_{t}}$.
• "Bad move" (${\displaystyle d(X_{t},Y_{t})}$ increases by 1):
• "Neutral move" (${\displaystyle d(X_{t},Y_{t})}$ is unchanged):