TExcelTAD
Home › Randomized Algorithms & Probabilistic Analysis › Coupling: Proving a Chain Mixes

Coupling: Proving a Chain Mixes

Computing d(t)d(t) exactly, as in Stationary Distributions and Mixing Time, is impossible for chains with 21002^{100} states. Coupling proves upper bounds on mixing times by a probabilistic argument instead of linear algebra: run two copies of the chain, from different starts, on cleverly shared randomness, and show they meet quickly. Once they meet, they move together, and the starting point has been forgotten. The method goes back to Doeblin (1938); it became an algorithmic tool through Aldous (1983) and, with path coupling, Bubley and Dyer (1997). This lesson proves the coupling lemma and applies it to the hypercube, with a complete proof, and to the cycle.

The coupling lemma

A coupling of two distributions μ\mu and ν\nu on Ω\Omega is a pair of random variables (X,Y)(X, Y) defined together, with X∼μX \sim \mu and Y∼νY \sim \nu.

Lemma. For every coupling, ∥μ−ν∥TV≤Pr⁡[X≠Y]\lVert \mu - \nu \rVert_{TV} \le \Pr[X \ne Y]. (Some coupling attains equality.)

Proof. For any event AA, μ(A)−ν(A)=Pr⁡[X∈A]−Pr⁡[Y∈A]≤Pr⁡[X∈A,Y∉A]≤Pr⁡[X≠Y]\mu(A) - \nu(A) = \Pr[X \in A] - \Pr[Y \in A] \le \Pr[X \in A, Y \notin A] \le \Pr[X \ne Y]. Take the maximum over AA. □\square

For chains, a Markovian coupling is a process (Xt,Yt)(X_t, Y_t) in which each coordinate on its own is a copy of the chain, and the two stay together once they meet. Let τ\tau be the meeting time. Applying the lemma at time tt,

∥Pt(x,⋅)−Pt(y,⋅)∥TV≤Pr⁡[Xt≠Yt]=Pr⁡[τ>t]when X0=x, Y0=y.\lVert P^t(x, \cdot) - P^t(y, \cdot) \rVert_{TV} \le \Pr[X_t \ne Y_t] = \Pr[\tau > t] \quad \text{when } X_0 = x,\ Y_0 = y .

Starting Y0Y_0 from π\pi instead (so Yt∼πY_t \sim \pi for all tt) gives d(t)≤max⁡x,yPr⁡x,y[τ>t]d(t) \le \max_{x, y} \Pr_{x,y}[\tau > t]. To bound the mixing time it therefore suffices to design a coupling that meets quickly from every pair of starts.

The hypercube: a complete proof

The lazy random walk on {0,1}n\{0, 1\}^n can be described as: pick a coordinate ii uniformly and a bit bb uniformly, and set xi=bx_i = b. (With probability 12\frac12 the bit is already bb and nothing changes, so this is exactly the lazy walk that flips a random coordinate with probability 12\frac12.)

Coupling: both copies use the same ii and the same bb in every step.

After coordinate ii has been chosen once, both copies have xi=bx_i = b for the last bb written there, so they agree on ii forever. Hence they coincide as soon as every coordinate has been chosen at least once, which is a coupon collector process.

Theorem. For the lazy walk on {0,1}n\{0, 1\}^n, d(t)≤ne−t/nd(t) \le n e^{-t/n}, so tmix(ε)≤nln⁡n+nln⁡1εt_{\text{mix}}(\varepsilon) \le n \ln n + n \ln \frac{1}{\varepsilon}.

Proof. A fixed coordinate is never chosen in tt steps with probability (1−1n)t≤e−t/n(1 - \frac1n)^t \le e^{-t/n}. By a union bound over the nn coordinates, Pr⁡[τ>t]≤ne−t/n\Pr[\tau > t] \le n e^{-t/n}, and by the coupling lemma d(t)≤ne−t/nd(t) \le n e^{-t/n}. This is at most ε\varepsilon once t≥nln⁡n+nln⁡(1/ε)t \ge n \ln n + n \ln(1/\varepsilon). □\square

The exact answer is about 12nln⁡n\frac12 n \ln n (the chain shows a cutoff there: the distance drops from near 1 to near 0 in a window of O(n)O(n) steps), so the coupling bound is off by a factor 2, a typical price for a short proof. The program runs the coupling from opposite corners, measures how often the copies are still apart after tt steps, and compares with the bound and with the exact distance (computed with the weight chain of the previous lesson).

python · try it yourself
import random
from math import comb, exp, log

def coupling_time(n, rng):
    x, y = [0] * n, [1] * n            # opposite corners: they differ everywhere
    differ, t = n, 0
    while differ:
        i, b = rng.randrange(n), rng.randrange(2)
        if x[i] != y[i]:
            differ -= 1
        x[i] = y[i] = b
        t += 1
    return t

def exact_tail(n, t):
    # Pr[some coordinate not chosen in t steps], by inclusion-exclusion
    return sum((-1) ** (k + 1) * comb(n, k) * (1 - k / n) ** t for k in range(1, n + 1))

def exact_d(n, steps):
    pi = [comb(n, w) / 2 ** n for w in range(n + 1)]
    dist, out = [1.0] + [0.0] * n, []
    for _ in range(steps + 1):
        out.append(sum(abs(p - q) for p, q in zip(dist, pi)) / 2)
        new = [p / 2 for p in dist]
        for w in range(n + 1):
            if w > 0:
                new[w - 1] += dist[w] * w / (2 * n)
            if w < n:
                new[w + 1] += dist[w] * (n - w) / (2 * n)
        dist = new
    return out

rng = random.Random(150)
n = 32
taus = [coupling_time(n, rng) for _ in range(1200)]
d = exact_d(n, 300)
H = sum(1 / k for k in range(1, n + 1))
print(f"n = {n}: mean coupling time {sum(taus) / len(taus):.1f}, coupon collector n H_n = {n * H:.1f}")
print("   t   exact d(t)   Pr[tau > t]: measured   exact   bound n e^(-t/n)")
for t in [40, 60, 80, 120, 160, 200]:
    print(f"{t:4}   {d[t]:10.4f}   {sum(x > t for x in taus) / len(taus):21.4f}   {exact_tail(n, t):.4f}   {min(1, n * exp(-t / n)):16.4f}")
tmix = next(t for t, v in enumerate(d) if v <= 0.25)
print(f"exact t_mix = {tmix}; coupling bound n ln n + n ln 4 = {n * log(n) + n * log(4):.0f}; (1/2) n ln n = {n * log(n) / 2:.0f}")
n = 32: mean coupling time 131.5, coupon collector n H_n = 129.9
   t   exact d(t)   Pr[tau > t]: measured   exact   bound n e^(-t/n)
  40       0.5945                  1.0000   1.0000             1.0000
  60       0.3303                  0.9992   0.9984             1.0000
  80       0.1786                  0.9575   0.9493             1.0000
 120       0.0500                  0.5375   0.5271             0.7526
 160       0.0140                  0.1867   0.1835             0.2156
 200       0.0039                  0.0617   0.0547             0.0618
exact t_mix = 70; coupling bound n ln n + n ln 4 = 155; (1/2) n ln n = 55

The exact distance falls well before the copies have met: the coupling time is an upper bound on mixing, not the mixing time itself.

The cycle: couple by moving one copy

For the lazy walk on the cycle CnC_n, using the same step in both copies would keep their distance fixed forever. A better coupling moves one of them: in each step, flip a fair coin to decide which copy moves, and move it one step clockwise or counterclockwise with probability 12\frac12 each. Each copy on its own still stays with probability 12\frac12 and moves either way with probability 14\frac14, so this is a valid coupling. The clockwise distance DtD_t from one copy to the other then performs an unbiased walk on {0,…,n}\{0, \ldots, n\} that stops at 0 or nn (where the copies meet). From D0=kD_0 = k the expected meeting time is k(n−k)≤n2/4k(n - k) \le n^2/4 (a gambler's-ruin calculation, Gambler's Ruin), so Markov's inequality gives

d(t)≤max⁡x,yPr⁡[τ>t]≤n24t,tmix≤n2.d(t) \le \max_{x,y} \Pr[\tau > t] \le \frac{n^2}{4t}, \qquad t_{\text{mix}} \le n^2 .

The exact values from the previous lesson, about 0.095 n20.095\,n^2, show the right order of growth with a smaller constant.

python · try it yourself
import random

def cycle_coupling_time(n, x, y, rng):
    t = 0
    while x != y:
        step = rng.choice((-1, 1))
        if rng.random() < 0.5:
            x = (x + step) % n
        else:
            y = (y + step) % n
        t += 1
    return t

rng = random.Random(151)
print("  n   mean meeting time from opposite points   n^2/4")
for n in [8, 16, 32]:
    times = [cycle_coupling_time(n, 0, n // 2, rng) for _ in range(500)]
    print(f"{n:3}   {sum(times) / len(times):38.1f}   {n * n / 4:5.0f}")
  n   mean meeting time from opposite points   n^2/4
  8                                     16.5      16
 16                                     68.6      64
 32                                    254.3     256

In C++

The hypercube coupling in C++ for larger dimensions (fixed-seed std::mt19937; the stream differs from Python's). It tracks only the number of coordinates not yet chosen, which is all that the meeting time depends on.

cpp · try it yourself
#include <cmath>
#include <cstdio>
#include <random>
#include <vector>

int main() {
    std::mt19937 rng(150);
    std::printf("    n   mean coupling time (200 runs)   n H_n   n ln n\n");
    for (int n : {64, 256, 1024}) {
        double total = 0;
        for (int run = 0; run < 200; ++run) {
            std::vector<bool> chosen(n, false);
            int left = n;
            long long t = 0;
            while (left > 0) {
                int i = rng() % n;
                ++t;
                if (!chosen[i]) { chosen[i] = true; --left; }
            }
            total += t;
        }
        double H = 0;
        for (int k = 1; k <= n; ++k) H += 1.0 / k;
        std::printf("%5d   %29.1f   %5.0f   %6.0f\n", n, total / 200, n * H, n * std::log(n));
    }
}
    n   mean coupling time (200 runs)   n H_n   n ln n
   64                           294.4     304      266
  256                          1585.1    1568     1420
 1024                          7602.1    7689     7098

Beyond simple couplings

  • Card shuffling. "Take the top card and insert it at a random position" mixes a deck of nn cards in about nln⁡nn \ln n steps; a coupling that matches cards by label proves it. Riffle shuffles need about 32log⁡2n\frac32 \log_2 n shuffles, the famous "seven shuffles" for 52 cards (Bayer and Diaconis, 1992); see Card Shuffling.
  • Path coupling (Bubley and Dyer, 1997). It is enough to couple adjacent states (differing in one position) so that their expected distance shrinks by a factor 1−α1 - \alpha per step; the triangle inequality then extends the contraction to all pairs and gives tmix(ε)≤1αln⁡diam⁡εt_{\text{mix}}(\varepsilon) \le \frac{1}{\alpha}\ln\frac{\operatorname{diam}}{\varepsilon}. This is how the colouring and independent-set chains of MCMC Sampling are analysed.

Test yourself

What does the coupling lemma say?

  1. ∥μ−ν∥TV≥Pr⁡[X≠Y]\lVert \mu - \nu \rVert_{TV} \ge \Pr[X \ne Y] for every coupling
  2. ∥μ−ν∥TV≤Pr⁡[X≠Y]\lVert \mu - \nu \rVert_{TV} \le \Pr[X \ne Y] for every coupling
  3. Two chains always meet
  4. Couplings exist only for reversible chains

In the hypercube coupling, why do the two copies agree on coordinate ii after it is chosen once?

  1. Because the walk is lazy
  2. Because both copies set xix_i to the same random bit bb
  3. Because nn is a power of two
  4. Because the copies start at opposite corners

Which bound does the coupling give for the lazy walk on {0,1}n\{0,1\}^n?

  1. tmix(ε)≤nln⁡n+nln⁡(1/ε)t_{\text{mix}}(\varepsilon) \le n \ln n + n \ln(1/\varepsilon)
  2. tmix≤nt_{\text{mix}} \le n
  3. tmix≤2nt_{\text{mix}} \le 2^n
  4. tmix≤n2t_{\text{mix}} \le n^2

For the lazy walk on a cycle, why does the good coupling move only one of the two copies per step?

  1. To save random bits
  2. So that their distance performs an unbiased random walk and hits 0, instead of staying constant
  3. Because the cycle is bipartite
  4. To make the chain reversible