Chapter I
Needles and Solitaire
In 1777 Georges-Louis Leclerc, Comte de Buffon published the answer to a question he had posed decades earlier. Drop a needle on a floor of parallel boards. If the needle is as long as a board is wide, it crosses a crack with probability . The problem belongs to probability theory, but it can be run backwards: drop enough needles, count the crossings, and estimate . A few people tried in the nineteenth century. It was a curiosity, because deterministic formulas gave far faster.
The idea became a method in 1946. Stanislaw Ulam, recovering from an illness, tried to work out the chance that a game of solitaire comes out. The combinatorics was hopeless, but he saw that playing a hundred games and counting would give a good estimate. He told John von Neumann, who at once saw how to apply it to the problem that mattered at Los Alamos: how neutrons scatter, split nuclei and multiply inside a bomb. Each neutron's life could be simulated as a sequence of random events and repeated thousands of times on the ENIAC. Nicholas Metropolis suggested the name, after the casino where Ulam's uncle liked to gamble. Enrico Fermi, it later emerged, had used similar sampling by hand in Rome in the 1930s without publishing it.
Chapter II
Walking Towards the Answer
Plain sampling fails when the interesting states are rare. In a dense liquid, almost every random placement of the molecules has two overlapping, so almost every sample is worthless. In 1953 a group at Los Alamos, Metropolis, Arianna Rosenbluth, Marshall Rosenbluth, Augusta Teller and Edward Teller, found a way around it. Start with some arrangement. Propose moving one molecule slightly. If the move lowers the energy, accept it. If it raises the energy, accept it only with a probability that shrinks as the energy rises. Otherwise stay put. The resulting random walk visits each arrangement in proportion to its probability in thermal equilibrium, as ergodic theory guarantees for a walk of this kind.
The paper carried Metropolis's name first, and the method is named after him. Marshall Rosenbluth later said that he and Arianna had worked out the algorithm and that she had written the program, and the question of credit has been discussed ever since.
Computing by chance needs random numbers, and computers cannot make them. Von Neumann joked that anyone using arithmetic to produce random digits was "in a state of sin". The generators in use were simple formulas that looked random. In 1968 George Marsaglia showed that the most common kind has a hidden structure: its points in three dimensions lie on a few planes. Generators have been tested far more carefully ever since. Others, beginning with Halton and Ilya Sobol, gave up randomness deliberately, choosing points spread more evenly than chance would place them.
Chapter III
A Closer Look: Buffon's Needle
Let the boards have width 1 and the needle length 1. Where the needle lands is described by two random numbers: the distance from its centre to the nearest crack, between 0 and , and its angle to the cracks, between 0 and . The needle crosses a crack when . The probability is the area under that curve divided by the area of the rectangle:
So if of needles cross, . A computer simulation, with needles dropped by a pseudorandom generator, gives:
| Needles | Crossings | Estimate | Error |
|---|---|---|---|
| 100 | 69 | 2.899 | 0.24 |
| 10,000 | 6,346 | 3.1516 | 0.010 |
| 1,000,000 | 637,106 | 3.13920 | 0.0024 |
Each hundredfold increase in effort buys about one more correct digit. The standard deviation of the estimate is about , which is 0.24, 0.024 and 0.0024 for these three sizes, close to what the simulation shows. This is the square-root law, and it is slow: a hundred million needles give only about four correct digits.
It is also why a famous result is suspicious. In 1901 the Italian mathematician Mario Lazzarini reported 3,408 throws of a needle five-sixths as long as the board width, with 1,808 crossings. His estimate was , correct to six decimal places. The typical error for that many throws is about 0.05. Getting within by luck is wildly unlikely, and the numbers look chosen to produce the well-known fraction .
The square-root law has one great virtue: it does not depend on dimension. A grid with 10 points in each direction needs points in 100 dimensions, but Monte Carlo error depends only on the number of samples. That is why Monte Carlo wins for the many-dimensional averages of physics, statistics and finance.
Chapter IV
Everywhere at Once
The 1953 algorithm spread slowly. W. Keith Hastings generalised it in 1970, and in 1984 Stuart and Donald Geman's Gibbs sampler brought it to image processing. In 1990 Alan Gelfand and Adrian Smith showed statisticians that it could fit Bayesian models of realistic size, and within a decade Markov chain Monte Carlo had changed how statistics is done. It now runs in statistical mechanics, in the reconstruction of evolutionary trees and in the training of some machine-learning models. One question is still hard in almost every case: how long must the walk run before its samples can be trusted? For all but a few examples, the honest answer is that nobody can prove it, and users rely on diagnostics and experience. A close relative takes random steps downhill instead of wandering. It is the stochastic gradient descent of continuous optimisation, and it trains neural networks.