MIT 6.1220 — Lecture 21
Random Walks (Part II)
Problem. (Card Shuffling) Among all permutations of a deck of cards, pick one at random.
The challenge is that we cannot just define a map , because is huge.
Meta-Algorithm. To efficiently sample from a very large probability distribution ,
just define a Markov chain that converges to as .
Solution. (Card Shuffling) In this particular case: riffle-shuffle seven times.
To clarify the rules a little:
We are told that , and we can efficiently compute given .
We can sample from simple distributions (e.g. , , coin-flipping).
Problem. (Independent Set) Given a graph (e.g. a hexagonal lattice), sample an independent set of vertices. In the language as above, we have . So is computable, but is not.
Solution. (Independent Set) Start with an independent set . Repeat the following process.
Process. Pick a vertex uniformly at random.
If , then remove with probability .
If and can be added to , then add with probability .
We claim that is the unique stationary distribution of , and that as .
Proof: The desired (uniform) distribution is stationary with respect to . This is because is symmetric:
It thus remains to check convergence and uniqueness.
Uniqueness: The Markov chain has a unique recurrent component; that's because it's strongly connected.
Convergence: The Markov chain is aperiodic because there are some cycles of length .
Therefore, must be the stationary distribution of .
Remark. The constant is necessary to encourage “mixing” and avoid periodicity.
We'd like to generalize the approach from above. More specifically,
Problem. Given , determine a Markov chain which converges to the distribution .
The tricky part is guaranteeing that the we want truly is stationary with respect to . Here's how.
Definition (Metropolis-Hastings Algorithm). Say our target distribution is , and let be any Markov chain. We don't know , but we do know , so we may create a new Markov chain like so:
Remark. When the target distribution is uniform, Metropolis-Hastings returns the Markov chain
The claim, of course, is that our target is always stationary with respect to this choice of .
Remark. This new Markov chain is equivalent to the following:
Starting at state , sample a transition according to .
Actually move to with probability . Otherwise, stay at .
The acceptance factor, in a sense, adjusts our generic Markov chain to account for the weights desired.
To see the motivation and validity for this selection of , we introduce the notion of reversible Markov chains.
Definition (Reversible). Informally, a Markov chain is reversible if it “looks the same” viewed forward and backwards.
Mathematically, this reads , for all pairs of states and all times . However, the RHS depends on the probability distribution of states.
What distribution should we choose? The stationary distribution , naturally. Then:
The above is detailed balance: for all states , we have .
Example. All random walks on undirected weighted graphs are reversible.
The choice to pick the stationary distribution for our was not arbitrary.
Claim. If is a Markov chain and is a distribution satisfying detailed balance, then must be stationary.
Proof: Intuitively, detailed balance locally says that the flow along equals the flow along . Meanwhile, stationary globally says that the net flow out of any state is zero.
The local condition implies the global one.
Claim. In Metropolis-Hastings, the target distribution is stationary with respect to .
Proof: The upshot of all these definitions is that it suffices to check satisfies detailed balance.
Suppose, WLOG, that the acceptance factor is less than . Then detailed balance says:
Meanwhile, the acceptance factor is , since its ratio is the reciprocal of the one above. So as well. So indeed, detailed balance is satisfied, and we win.
Of course, Metropolis-Hastings doesn't do all the work—we still need to check for convergence, which requires checking recurrent components and periodicity of .
Remark. Metropolis-Hastings isn't all that necessary, either. Our solution to Independent Set from earlier showed was stationary by noting that was uniform and was symmetric.
Problem. (Graph Colorings) Given a graph , sample a valid coloring of its vertices with colors, uniformly at random across all valid colorings.
Solution. (Graph Colorings) Begin with a graph coloring . Repeat the following process.
Process. Pick a vertex uniformly at random, and a color uniformly at random.
If it will yield a valid graph coloring, then update .
We claim the uniform distribution is the unique stationary distribution of , and that convergence holds.
Proof: To show that is a stationary distribution, just note that is uniform and is symmetric:
It remains to show uniqueness. The main difficulty is connectivity.
Claim. For any pair of -colorings , there is a sequence of Markov chain transitions .
Proof: It suffices to find for which has fewer disagreements than .
Pick some vertex for which . If updating is permitted, we're done.
Otherwise, for some neighbor . The key is that any such must also be a disagreeing vertex. Thus, we can recolor every such neighbor without creating any new disagreements; this is possible because .
So if for some neighbor , just recolor , reducing to the easy case.
So connectivity holds. Aperiodicity does, too, as there are edges . I'm convinced.
Remark. This fails when because the Markov chain is disconnected. (Take and .)