Use of random numbers in the Metropolis algorithm

In the Metropolis algorithm, we accept or reject based on following criterion in the $NVT$ ensemble: $$e^ {(E_{\text{new}} - E_{\text{old}})\,/ \,kT } \ge \text{random}(0,1).$$

Why does the uniformly distributed random numbers work here? How does it work?

• I went ahead and answered this, but it doesn't actually involve any physics (though the Metropolis algorithm comes up often in physics applications). Might be better on math.SE?
– Kyle
Aug 15 '13 at 18:22
• I need more insights here from statistical mechanics, Monte Carlo point of view. Aug 15 '13 at 18:43

You stated the acceptance criterion:

$$e^{(E_\mathrm{new}-E_\mathrm{old})/kT} \geq \mathrm{random}(0,1)$$

The left hand side expresses a ratio of likelihoods $\mathcal{L}_\mathrm{new}/\mathcal{L}_\mathrm{old}$ of a new state and an old state. If the new state is more likely than the old state, $\mathcal{L}_\mathrm{new}/\mathcal{L}_\mathrm{old} \gt 1$, so the acceptance criterion is automatically fulfilled.

If the new state is less likely than the old state, $0 \lt \mathcal{L}_\mathrm{new}/\mathcal{L}_\mathrm{old} \lt 1$. Now the acceptance criterion is fulfilled randomly. The more unlikely the new state (as compared to the old state), the more unlikely it is to be accepted, but there is always a finite probability of acceptance (well, up to machine precision anyway).

In practice, this means that as the space of states is explored, typically the algorithm will move toward more likely states, but will occasionally move against the gradient of the likelihood. This is important if there are local maxima in the likelihood distribution so that the algorithm can "get out" of a local maximum to keep exploring other regions of the space of states. Without this feature, the algorithm would get stuck at the first little peak in the likelihood distribution that it encountered. It also allows proper exploration of the vicinity of a maximum, with the number of occupations of a state being proportional to the relative likelihood of the state (as the number of iterations approaches $\infty$).

• But the actual confusion is, how to convince someone that a random number, that too from an uniform distribution, can be used to decide acceptance/rejection? Aug 15 '13 at 18:36
• That's what my last paragraph is talking about... naively, you would want $\mathcal{L}_\mathrm{new}/\mathcal{L}_\mathrm{old} > 1$ as an acceptance parameter (always accept more likely states), but to fully explore the possible states you need to be able to 1) avoid getting stuck at local features and 2) explore the region around a likelihood maximum. The random number allows occasional (random) unlikely steps that achieve these two things.
– Kyle
Aug 15 '13 at 18:49
• @cosmicraga: The simple fact that you're getting a probability, and you want to simulate from it, means you need to draw a random 0 or 1 with that probability. The simplest way to do that is with a uniform. More generally, you're trying to satisfy the detailed balance property. Aug 15 '13 at 18:53
• It's not correct that you are getting a probability. What you have on the left hand side is a ratio of likelihoods that you evaluate at a particular point. Likelihoods are non-normalized probability densities. Their point values need not be between zero and one. Aug 16 '13 at 2:43