Mixing of Random Walks via the Spectral Gap
A random walk on a connected non-bipartite graph converges to its stationary distribution . How fast is the question behind every sampling algorithm and every "random walk explores the graph" argument. Stationary Distributions and Mixing Time measured mixing times by computation and coupling; here we prove the spectral bound: the distance to shrinks by a factor per step of the lazy walk. Combined with Cheeger's inequality, this says a walk mixes fast exactly when the graph has no sparse cut.
The lazy walk in spectral form
Let be connected and use column vectors for distributions, with the lazy walk matrix
where is the normalized Laplacian. So is similar to the symmetric matrix , whose eigenvalues are , with for the eigenvector . Laziness makes every nonnegative, which removes the oscillation of bipartite graphs ( becomes ).
Theorem. For the lazy walk started at vertex , after steps, for every vertex ,
Proof. Let be an orthonormal eigenbasis of and write . Then . The term is with , so it equals . For the rest,
by Cauchy-Schwarz, , and (the rows of an orthogonal matrix are unit vectors).
Summing over , the total-variation distance satisfies , so
The relaxation time sets the scale, up to a logarithmic factor; and the scale is right, since for reversible chains (Levin, Peres and Wilmer, Theorem 12.5). With Cheeger's inequality , a graph of conductance mixes in steps (for bounded degree ratio), and a sparse cut forces slow mixing.
Watching it happen
The lab runs the lazy walk from node 0 on three 12-node graphs: a cycle, a barbell (two 6-cliques joined by one edge) and a 4-regular circulant (jumps of 1 and 5). It shows the exact distribution after steps and the total-variation distance to ; the mixing times (first with distance at most ) are 14, 29 and 4.
The program computes the same three walks exactly, together with , the relaxation time and the spectral upper bound on .
import numpy as np
n = 12
graphs = {
"cycle": [(i, (i + 1) % n) for i in range(n)],
"barbell": [(a + s, b + s) for s in (0, 6) for a in range(6) for b in range(a + 1, 6)] + [(5, 6)],
"circulant": [(i, (i + j) % n) for i in range(n) for j in (1, 5)],
}
print("graph nu_2 2/nu_2 t_mix from node 0 spectral bound on t_mix(1/4)")
for name, edges in graphs.items():
A = np.zeros((n, n))
for u, v in edges:
A[u, v] = A[v, u] = 1
d = A.sum(axis=1)
s = 1 / np.sqrt(d)
nu2 = float(np.linalg.eigvalsh(np.eye(n) - s[:, None] * A * s[None, :])[1])
M = (np.eye(n) + A / d[None, :]) / 2 # column-stochastic lazy walk
pi = d / d.sum()
p = np.zeros(n); p[0] = 1.0
t = 0
while 0.5 * np.abs(p - pi).sum() > 0.25:
p = M @ p; t += 1
bound = 2 / nu2 * np.log(n / (2 * 0.25) * np.sqrt(d.max() / d.min()))
print(f"{name:10} {nu2:7.4f} {2 / nu2:7.2f} {t:17} {bound:27.1f}")graph nu_2 2/nu_2 t_mix from node 0 spectral bound on t_mix(1/4)
cycle 0.1340 14.93 14 47.4
barbell 0.0507 39.48 29 129.1
circulant 0.5000 4.00 4 12.7
The ordering of the three graphs is exactly the ordering of their spectral gaps, and the relaxation time is within a small factor of the true mixing time. The spectral bound is an over-estimate by the logarithmic factor, which matters little for asymptotics.
The pointwise bound in action
The theorem is a bound for each target vertex. The program follows the walk on the barbell from vertex 0 and compares the worst deviation with .
import numpy as np
n = 12
edges = [(a + s, b + s) for s in (0, 6) for a in range(6) for b in range(a + 1, 6)] + [(5, 6)]
A = np.zeros((n, n))
for u, v in edges:
A[u, v] = A[v, u] = 1
d = A.sum(axis=1)
s = 1 / np.sqrt(d)
nu = np.linalg.eigvalsh(np.eye(n) - s[:, None] * A * s[None, :])
omega2 = 1 - nu[1] / 2
M = (np.eye(n) + A / d[None, :]) / 2
pi = d / d.sum()
p = np.zeros(n); p[0] = 1.0
for t in range(1, 121):
p = M @ p
if t in (1, 10, 30, 60, 120):
dev = float(np.max(np.abs(p - pi) * np.sqrt(d[0] / d)))
print(f"t = {t:3}: max_b |p_t(b) - pi(b)| sqrt(d_a/d_b) = {dev:.3e} omega_2^t = {float(omega2 ** t):.3e}")t = 1: max_b |p_t(b) - pi(b)| sqrt(d_a/d_b) = 4.194e-01 omega_2^t = 9.747e-01
t = 10: max_b |p_t(b) - pi(b)| sqrt(d_a/d_b) = 6.834e-02 omega_2^t = 7.737e-01
t = 30: max_b |p_t(b) - pi(b)| sqrt(d_a/d_b) = 4.085e-02 omega_2^t = 4.632e-01
t = 60: max_b |p_t(b) - pi(b)| sqrt(d_a/d_b) = 1.892e-02 omega_2^t = 2.145e-01
t = 120: max_b |p_t(b) - pi(b)| sqrt(d_a/d_b) = 4.059e-03 omega_2^t = 4.602e-02
The deviation stays below throughout, and after the first few steps it decays at exactly the rate (from to it shrinks by ): the walk's distance to is dominated by the second eigenvector, which is positive on one clique and negative on the other, i.e. by the imbalance of probability between the two halves that the bridge slowly repairs.
In C++
The spectral bound becomes useful when the graph is too large to diagonalize. On the hypercube (1024 vertices, , ), the C++ program evolves the exact distribution and reports the first with total-variation distance at most , against the spectral bound .
#include <cmath>
#include <cstdio>
#include <vector>
int main() {
const int d = 10, n = 1 << d;
std::vector<double> p(n, 0.0), q(n);
p[0] = 1.0;
const double pi = 1.0 / n; // regular graph: uniform stationary distribution
for (int t = 1; t <= 200; ++t) {
for (int v = 0; v < n; ++v) {
double s = 0;
for (int i = 0; i < d; ++i) s += p[v ^ (1 << i)];
q[v] = 0.5 * p[v] + 0.5 * s / d; // lazy step
}
p.swap(q);
double tv = 0;
for (double x : p) tv += std::fabs(x - pi);
tv /= 2;
if (t % 5 == 0 || tv <= 0.25) std::printf("t = %3d: TV distance %.4f\n", t, tv);
if (tv <= 0.25) {
double nu2 = 2.0 / d;
std::printf("t_mix(1/4) = %d; spectral bound (2/nu_2) ln(2n) = %.1f\n", t, 2.0 / nu2 * std::log(2.0 * n));
break;
}
}
}t = 5: TV distance 0.7399
t = 10: TV distance 0.4429
t = 15: TV distance 0.2667
t = 16: TV distance 0.2395
t_mix(1/4) = 16; spectral bound (2/nu_2) ln(2n) = 76.2
The true mixing time, 16 steps, is of order (plus a term of order ) and about a fifth of the bound: the spectral argument charges where coupling shows suffices, an instance of the "cutoff phenomenon" that the argument cannot see.
Test yourself
What are the eigenvalues of the lazy walk matrix in terms of the normalized Laplacian eigenvalues ?
Which bound did the lesson prove for the lazy walk started at ?
Why is the barbell's mixing time so much larger than the circulant's, although both have 12 vertices?
- The barbell has more edges
- Its single bridge gives tiny conductance, hence a tiny (Cheeger) and a large relaxation time
- The barbell is bipartite
- The circulant is not regular
How do relaxation time and mixing time compare for reversible chains?
- They are unrelated
- Mixing time is within a logarithmic factor of the relaxation time , from both sides up to constants
- Mixing time is always exactly the relaxation time
- Mixing time is the square of the relaxation time