TL;DR
In 1953 five authors at Los Alamos described a way to estimate the thermal properties of a dense fluid made of interacting molecules. Instead of averaging over random arrangements of the molecules, they run a random walk over arrangements in which each proposed move is accepted or rejected by a simple rule. The rule makes the walk spend time in each arrangement in proportion to its Boltzmann weight, so a plain average along the walk is the thermal average. They tested it on a two-dimensional system of hard disks and checked the result against known approximations.
Where you'll see it: molecular simulation of liquids and proteins, the sampling engine behind Bayesian statistics, and the Markov chain Monte Carlo methods used throughout machine learning.
The problem
Suppose you want the pressure of a liquid made of several hundred molecules at a fixed temperature. Statistical mechanics says that every arrangement of the molecules, every point in configuration space, has a weight that depends on its energy. For a system at temperature with energy , the weight of a state is proportional to , where is Boltzmann's constant. This is the Canonical Ensemble picture. A thermal average of any quantity is
where stands for the positions of all particles, so the integral runs over a -dimensional space in two dimensions (or in three). The energy splits into a kinetic part that depends on momenta and a potential part that depends on positions. The momentum part can be averaged analytically, which is why the paper only has to deal with positions.
A several-hundred-dimensional integral cannot be done on a grid. The obvious fix is Monte Carlo integration: pick random configurations and average. The paper points out why this fails for dense fluids. A random placement of hundreds of molecules almost always has two of them overlapping, which gives a huge energy and therefore a weight that is essentially zero. Most of the samples contribute nothing, and the few that do dominate the answer with huge variance. What is needed is a way to visit the configurations that matter, the low-energy ones, far more often than the rest.
This is the same problem that Importance Sampling addresses by reweighting samples drawn from a convenient distribution. The paper takes a different route: it does not reweight at all. It builds a process whose visits already have the right frequencies.
Key idea
Replace the random configurations by a walk. Start from any arrangement, pick one particle, move it by a small random displacement, and decide whether to keep the move with one rule:
- If the move lowers the energy, keep it.
- If the move raises the energy by , keep it with probability . Otherwise undo it.
Then count the current arrangement as a sample, whether or not the move was kept. This is a Metropolis Algorithm run on the space of configurations.
Think of a hiker on a landscape whose height is the energy. The hiker prefers to go downhill. Uphill steps are not forbidden; they are just less likely the steeper they are. Over a long walk the hiker spends time at each height in proportion to how many visits that height gets under the rule, and the rule is tuned so that the time spent at a point is proportional to .
- acceptance probability
The method
The box and the energy
The paper considers particles in a square of side . To avoid edge effects the square is treated as periodic: a particle leaving one side re-enters from the opposite side, and the distance between two particles is the shortest distance between one of them and any periodic image of the other. The paper uses this minimum distance and assumes the potential between two molecules falls off quickly, so only one image matters. The total energy is
The factor one half avoids counting each pair twice.
One move
A single step of the walk does the following for one particle .
- Propose a new position , where each component of is a uniform random number between and . The new position is equally likely anywhere in a square of side around the old one. The maximum displacement is a tunable number.
- Compute , the change in energy caused by this one move. Only pairs involving particle change, so this is cheap.
- If , accept. If , draw a uniform random number between 0 and 1 and accept if .
- If the move was rejected, the particle stays where it was.
Whether the move was accepted or not, the resulting configuration is recorded as one sample. Forgetting to record the old configuration after a rejection is a classic bug, and the paper states explicitly that the initial configuration must be counted again after a forbidden move.
Why this samples the right distribution
The paper proves the rule works in two parts: the walk can reach any configuration from any other, which it calls ergodicity, and the flow of samples between any two states is balanced in the right way.
The second part is easiest to see with a symmetric proposal. Let be the target weight of configuration . Because the proposal is symmetric, the probability of proposing from equals the probability of proposing from . Call that probability . The Metropolis rule accepts the move from to with probability . The flow of samples from to is therefore
The right-hand side is symmetric in and . So the flow from to equals the flow from to . This is the Detailed Balance condition, and a chain that satisfies it has as its stationary distribution. The paper reaches the same conclusion with a counting argument over an ensemble of systems: the number of systems moving from state to state must equal the number moving back, and that forces the ratio of populations to be .
Notice that the normalising constant never appears. Only ratios of weights are used, so the rule can be applied without knowing the total. That is why the method is practical in a space too large to normalise.
Hard disks
For the test case the paper uses rigid spheres in two dimensions. A pair of hard disks has energy zero when they do not overlap and infinite energy when they do. The energy change of a move is therefore either or , the acceptance probability is or , and the random number is not needed. A move is accepted exactly when it creates no overlap. The paper uses disks in a unit square, starting from a regular trigonal lattice.
Choosing the step size
The maximum displacement has to be chosen with care. If is too large, most proposed moves land on overlapping disks and are rejected, so the configuration hardly changes. If is too small, almost every move is accepted but each one moves little, so the configuration changes slowly. In both cases the walk takes much longer to reach equilibrium. The paper sets so that about half the moves are forbidden, which is a rule of thumb that appears in modern simulation codes too.
Pressure from the contacts
The paper does not compute the pressure directly from forces. It uses the virial theorem of Clausius, which relates the pressure to the average of the total force-times-distance product. For hard disks the virial term reduces to a single number: the density of other disks in contact with a given disk at the contact distance , which the paper reads off the radial distribution function. The pressure then follows from an equation of state with one measured quantity. The paper's work is therefore to estimate that contact density accurately as a function of the area per disk.
Results
The paper expresses the equation of state through the dimensionless quantity , where is the total area and is the area the disks would occupy in a close-packed arrangement. It compares three things: the Monte Carlo result, the free-volume theory of Wood, and a four-term virial expansion of the pressure in powers of the density.
A selection of the paper's table, with the Monte Carlo value first:
| Monte Carlo | Free volume theory | Four-term virial | |
|---|---|---|---|
| 1.32 | 6.43 | 6.72 | 5.35 |
| 1.80 | 2.93 | 2.94 | 2.68 |
| 4.04 | 0.677 | 0.990 | 0.667 |
Three findings matter.
- Near close packing, where is small, the Monte Carlo result stays close to the free-volume theory, and the virial expansion falls well below it.
- At large area, where is a few, the Monte Carlo result follows the four-term virial expansion, and the free-volume theory overshoots.
- The paper reports no sign of a phase transition in the range of densities it covered.
The virial fit that the paper gives is
Plugging in gives and a value of about , which matches the table. The paper's computing cost is also worth noting. One Monte Carlo cycle, in which every particle is moved once, took minutes on the MANIAC machine at Los Alamos, so each point on the pressure curve needed hours of running.
Why it mattered
The paper turned Monte Carlo from a way of estimating a small integral into a way of simulating a physical system. The acceptance rule it introduced is now called the Metropolis rule, and it is the basis of the Metropolis Algorithm. Hastings generalised it in 1970 to proposals that are not symmetric, which gives the Metropolis–Hastings algorithm used in statistics and machine learning today.
In chemistry and physics the method became the standard tool for simulating liquids, polymers, and magnetic systems at fixed temperature. In statistics the same idea, a walk whose visit frequencies match a target distribution, is the core of Markov Chain Monte Carlo. Any problem where a posterior or a Boltzmann-like distribution is known only up to a constant can use it, because the rule never needs the normalising constant.
Reading guide
Read the paper in this order, with these prerequisites in hand.
- The introduction. The question is the thermal average of a property for a fluid of interacting molecules. You need the idea of a Canonical Ensemble and of an average over states.
- The setup of the average. The energy is a sum over pairs, and the average is a ratio of integrals with weight . Read Expected Value first if the ratio of integrals is unfamiliar.
- The move and the proof. This is the heart of the paper. Read Metropolis Algorithm for the rule, Detailed Balance for the balance argument, and Markov Chain for the idea of a walk with a stationary distribution. The uniform displacement is described in Uniform Distribution.
- The comparison with plain sampling. This is where the paper explains why random placement fails. Monte Carlo Method gives the background, and Importance Sampling shows the reweighting alternative that the paper avoids.
- The virial pressure. The paper's pressure formula uses the virial theorem and a contact density. Standard textbooks on liquids cover this; the graph has no node for it yet.
- The results. The averages along the walk are justified by the Law of Large Numbers. Check the table against the free-volume and virial formulas.
- The virial coefficients. Cluster integrals are a separate topic. You can skip it on a first read.
Check yourself
QuestionRecall: a proposed move lowers the energy of the system. Does the Metropolis rule accept it, reject it, or accept it with some probability?Show answer
It is always accepted. The rule accepts any move with outright, because the ratio of target weights is at least one. Only uphill moves are accepted with a probability less than one.
QuestionA move raises the energy by . What is the probability it is accepted?Show answer
The acceptance probability is . The random number is drawn uniformly between 0 and 1, and the move is kept when is less than 0.449. So a little under half of such moves are kept.
QuestionWhy did the authors not simply place random configurations and weight each by ?Show answer
Dense configurations are almost always overlapping, which gives huge energies and weights close to zero. Most samples contribute nothing, and the estimate has very large variance. The walk instead spends its time in the configurations that have large weight, so each sample counts for something.
QuestionA run makes 1,000 proposed moves and accepts 400 of them. How many configurations are recorded as samples, and why?Show answer
Recorded samples number 1,000, one per proposed move, whether accepted or not. A rejected move leaves the configuration unchanged, but that unchanged configuration still has to be counted. Dropping the rejected steps would bias the average toward the configurations the walk leaves most easily.
QuestionIn the hard-disk case the energy change of any move is either or . What does the Metropolis rule reduce to, and why does that simplify the simulation?Show answer
Moves that create no overlap have and are accepted, and moves that create an overlap have and are rejected. No random number is needed, so the only computation per move is an overlap test against nearby disks.
Sources
- Metropolis, N., Rosenbluth, A. W., Rosenbluth, M. N., Teller, A. H., and Teller, E. (1953). Equation of State Calculations by Fast Computing Machines. The Journal of Chemical Physics. https://doi.org/10.1063/1.1699114
- Hastings, W. K. (1970). Monte Carlo sampling methods using Markov chains and their applications. Biometrika. See Metropolis–Hastings algorithm.
- Monte Carlo method