Skip to content
Field Atlas

Atlas / Mathematics / The Computation Thread

Field · Emerged 1946 – 1953

Monte Carlo Methods

How can randomness compute answers that careful deterministic methods cannot reach?

4 chapters5 min read6 turning points1 open problem

Branched from
Numerical Analysis + Probability Theory
Branched into
Not yet surveyed past here
Figures
Georges-Louis Leclerc, Comte de Buffon, John von Neumann, Stanislaw Ulam, Nicholas Metropolis, Edward Teller, Arianna Rosenbluth, Marshall Rosenbluth, Ilya Sobol, George Marsaglia

In brief

A Monte Carlo method answers a question by simulating chance. To find the average of a quantity over some huge space, such as all the arrangements of a million atoms or all the paths a neutron might take, pick random samples and average over them. The law of large numbers guarantees that the answer converges, and the central limit theorem says how fast: the error shrinks like one over the square root of the number of samples, whatever the dimension of the space.

The idea is old, as Buffon's needle of 1777 shows, but it became a method at Los Alamos in 1946–49, when Stanislaw Ulam and John von Neumann saw that the new electronic computers could play games of chance millions of times. In 1953 the Metropolis algorithm showed how to sample from the complicated probability distributions of physics by a random walk. That idea, Markov chain Monte Carlo, spread from physics to statistics in the 1990s and is now among the most used algorithms in science.

Key ideas

Estimation by samplingEnters 1777

Write the unknown quantity as the average of some random outcome, then simulate the outcome many times and average. Buffon's needle turns π\pi into a probability.

The square-root lawEnters 1946 – 1949

The error of a Monte Carlo average falls like 1/N1/\sqrt{N} for NN samples, in any dimension. One more correct digit costs a hundred times more samples, but high dimension costs nothing extra.

Pseudorandom numbersEnters 1968

Computers produce "random" numbers by a deterministic rule. A good rule passes statistical tests. A bad one hides patterns that can quietly bias every result.

Markov chain Monte CarloEnters 1953

To sample from a complicated distribution, run a random walk that proposes small moves and accepts or rejects each one by a simple rule. In the long run, the walk visits each state in proportion to its probability.

Quasi-Monte CarloEnters 1960 – 1967

Replace random samples by carefully spread-out deterministic points. For smooth problems the error can fall almost like 1/N1/N instead of 1/N1/\sqrt{N}.

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 2/π2/\pi. The problem belongs to probability theory, but it can be run backwards: drop enough needles, count the crossings, and estimate π\pi. A few people tried in the nineteenth century. It was a curiosity, because deterministic formulas gave π\pi 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 yy from its centre to the nearest crack, between 0 and 12\tfrac12, and its angle θ\theta to the cracks, between 0 and π2\tfrac{\pi}{2}. The needle crosses a crack when y≤12sin⁡θy \le \tfrac12 \sin\theta. The probability is the area under that curve divided by the area of the rectangle:

P=∫0π/212sin⁡θ dθ12⋅π2=1/2π/4=2π≈0.6366.P = \frac{\int_0^{\pi/2} \tfrac12 \sin\theta \, d\theta}{\tfrac12 \cdot \tfrac{\pi}{2}} = \frac{1/2}{\pi/4} = \frac{2}{\pi} \approx 0.6366.

So if HH of NN needles cross, π≈2N/H\pi \approx 2N/H. A computer simulation, with needles dropped by a pseudorandom generator, gives:

Needles NNCrossings HHEstimate 2N/H2N/HError
100692.8990.24
10,0006,3463.15160.010
1,000,000637,1063.139200.0024

Each hundredfold increase in effort buys about one more correct digit. The standard deviation of the estimate is about 2.37/N2.37/\sqrt{N}, 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 2⋅56⋅3408/1808=355/113=3.14159292 \cdot \tfrac56 \cdot 3408 / 1808 = 355/113 = 3.1415929, correct to six decimal places. The typical error for that many throws is about 0.05. Getting within 3×10−73 \times 10^{-7} by luck is wildly unlikely, and the numbers look chosen to produce the well-known fraction 355/113355/113.

The square-root law has one great virtue: it does not depend on dimension. A grid with 10 points in each direction needs 1010010^{100} 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.

Applications

Where it is used

  • Statistical physics↗ Physics · Statistical Mechanics

    Simulating matter

    Monte Carlo simulation of the Ising model and of liquids, glasses and polymers is a basic tool of statistical mechanics. It gives accurate numbers for critical temperatures and exponents where no exact solution exists.

    › Sources (1)
    • Landau, D. P. & Binder, K. (2014). A Guide to Monte Carlo Simulations in Statistical Physics, 4th edition. Cambridge University Press.
  • Evolution↗ Biology · Evolutionary Biology

    Bayesian family trees of species

    Programs such as MrBayes reconstruct evolutionary trees from DNA sequences by running Markov chain Monte Carlo over the enormous space of possible trees. The output is not a single tree but a probability for each branch.

    › Sources (1)
    • Huelsenbeck, J. P. & Ronquist, F. (2001). MRBAYES: Bayesian inference of phylogenetic trees. Bioinformatics 17(8): 754–755.
  • Finance

    Pricing by simulation

    Banks price complex financial contracts by simulating thousands of possible futures for interest rates and prices and averaging the payoffs, a method introduced by Phelim Boyle in 1977.

    › Sources (1)
    • Boyle, P. P. (1977). Options: a Monte Carlo approach. Journal of Financial Economics 4(3): 323–338.

Open problems

Where the map runs out

Open

How fast random colourings mix

Open as of 2026. Proved when the number of colours exceeds about 1.81 times the maximum degree.

Colour the vertices of a network with qq colours so that neighbours differ, and sample such colourings at random by repeatedly recolouring one vertex. The conjecture is that this walk gets close to random in a number of steps only slightly more than the number of vertices, whenever qq is at least the maximum number of neighbours plus two.

Why it is hard

The standard proofs couple two copies of the walk and show they meet. Mark Jerrum made that work in 1995 for twice the maximum degree, and Eric Vigoda in 1999 for 11/6 times it. Later work has lowered this only to about 1.81 times. Below that, local disagreements between the copies can spread, and no technique yet controls them all the way down to the conjectured threshold.

What resolving it unlocks

It is the test case for knowing when a Markov chain Monte Carlo run has actually converged, a question that every user of the method faces and that is rarely answered with proof.

› Sources (3)

Further reading

  1. Metropolis, N. (1987). The beginning of the Monte Carlo method. Los Alamos Science 15 (Special Issue): 125–130.

    A first-hand account of the Los Alamos years.

  2. Diaconis, P. (2009). The Markov chain Monte Carlo revolution. Bulletin of the American Mathematical Society 46(2): 179–205.

    A readable survey of how and why Markov chain Monte Carlo works.

  3. Robert, C. P. & Casella, G. (2004). Monte Carlo Statistical Methods, 2nd edition. Springer.

    The standard textbook from the statistical side.