Coupling: Proving a Chain Mixes
Computing exactly, as in Stationary Distributions and Mixing Time, is impossible for chains with 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 and on is a pair of random variables defined together, with and .
Lemma. For every coupling, . (Some coupling attains equality.)
Proof. For any event , . Take the maximum over .
For chains, a Markovian coupling is a process in which each coordinate on its own is a copy of the chain, and the two stay together once they meet. Let be the meeting time. Applying the lemma at time ,
Starting from instead (so for all ) gives . 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 can be described as: pick a coordinate uniformly and a bit uniformly, and set . (With probability the bit is already and nothing changes, so this is exactly the lazy walk that flips a random coordinate with probability .)
Coupling: both copies use the same and the same in every step.
After coordinate has been chosen once, both copies have for the last written there, so they agree on 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 , , so .
Proof. A fixed coordinate is never chosen in steps with probability . By a union bound over the coordinates, , and by the coupling lemma . This is at most once .
The exact answer is about (the chain shows a cutoff there: the distance drops from near 1 to near 0 in a window of 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 steps, and compares with the bound and with the exact distance (computed with the weight chain of the previous lesson).
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 , 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 each. Each copy on its own still stays with probability and moves either way with probability , so this is a valid coupling. The clockwise distance from one copy to the other then performs an unbiased walk on that stops at 0 or (where the copies meet). From the expected meeting time is (a gambler's-ruin calculation, Gambler's Ruin), so Markov's inequality gives
The exact values from the previous lesson, about , show the right order of growth with a smaller constant.
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.
#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 cards in about steps; a coupling that matches cards by label proves it. Riffle shuffles need about 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 per step; the triangle inequality then extends the contraction to all pairs and gives . This is how the colouring and independent-set chains of MCMC Sampling are analysed.
Test yourself
What does the coupling lemma say?
- for every coupling
- for every coupling
- Two chains always meet
- Couplings exist only for reversible chains
In the hypercube coupling, why do the two copies agree on coordinate after it is chosen once?
- Because the walk is lazy
- Because both copies set to the same random bit
- Because is a power of two
- Because the copies start at opposite corners
Which bound does the coupling give for the lazy walk on ?
For the lazy walk on a cycle, why does the good coupling move only one of the two copies per step?
- To save random bits
- So that their distance performs an unbiased random walk and hits 0, instead of staying constant
- Because the cycle is bipartite
- To make the chain reversible