Monte Carlo Basics
Monte Carlo methods estimate expectations and integrals by random sampling.
The simplest case is an expectation value
If are independent samples with the same distribution as , then
is the basic Monte Carlo estimator. Its statistical error decreases like under standard finite-variance assumptions.
Monte Carlo is not magic. It trades deterministic quadrature error for statistical uncertainty, and practical calculations must account for variance, bias, autocorrelation, sampling design, and reproducibility.
For how statistical error bars fit into broader numerical uncertainty budgets, see Error Estimates.
Expectations as Integrals
Section titled “Expectations as Integrals”Many integrals can be written as expectation values. If has density , then
Thus estimating an integral can be turned into estimating an average over random samples.
If the target integral is
and has finite volume , one may sample uniformly from and write
The Monte Carlo estimate is then
This is often useful in high-dimensional problems where tensor-product quadrature grids become impossible.
Sample-Mean Estimator
Section titled “Sample-Mean Estimator”Let
For independent samples , the sample mean
is unbiased:
Its variance is
The standard deviation of the estimator is therefore
This standard error is the origin of the Monte Carlo error scaling.
Estimated Error Bars
Section titled “Estimated Error Bars”The true is usually unknown. From independent samples one estimates it with
The estimated standard error is
For large and finite variance, the central limit theorem gives the approximate distribution
This approximation justifies familiar error bars, but it can fail badly for heavy-tailed observables, strong correlations, or insufficient equilibration.
Error Scaling and Cost
Section titled “Error Scaling and Cost”The rate is slow but dimension-independent in form. To reduce a Monte Carlo standard error by a factor of , one usually needs about times as many independent samples.
Monte Carlo is attractive when:
- the dimension is high;
- sampling from the relevant distribution is easier than gridding the domain;
- modest stochastic accuracy is enough;
- deterministic quadrature is blocked by complex geometry or many degrees of freedom.
Monte Carlo is unattractive when:
- the integrand has huge variance;
- rare events dominate the answer;
- samples are strongly correlated;
- signs or phases cause severe cancellations;
- systematic bias dominates statistical error.
The rate describes only statistical variance. It does not account for model error, discretization error, Markov-chain bias, floating-point error, or a poor estimator.
Importance Sampling
Section titled “Importance Sampling”Importance sampling changes the sampling distribution to reduce variance or make sampling possible.
Suppose the goal is
but samples are drawn from a proposal density . If wherever contributes, then
Thus
with .
The weights correct the change of sampling distribution. Good importance sampling makes less variable than direct sampling. Bad importance sampling can make variance enormous.
The support condition matters. If in a region where contributes, no finite weight can recover the missing region.
Self-Normalized Weights
Section titled “Self-Normalized Weights”Sometimes the target density is known only up to a normalization constant:
If samples come from , a common estimator for
is the self-normalized importance estimate
This estimator is generally biased at finite , though often consistent under suitable conditions. Large variation in the weights is a warning sign that the proposal distribution has poor overlap with the target.
Markov Chains and Autocorrelation
Section titled “Markov Chains and Autocorrelation”Many useful distributions cannot be sampled independently. Markov-chain Monte Carlo constructs a correlated sequence
whose stationary distribution is the desired target.
The same sample mean is often used, but the error bar changes. Positive autocorrelation reduces the effective number of independent samples:
where is an integrated autocorrelation time. Correspondingly,
This is why Markov-chain calculations need burn-in checks, autocorrelation estimates, blocking or batching analyses, and independent-chain comparisons.
Bias and Variance
Section titled “Bias and Variance”Monte Carlo error reports should separate statistical variance from bias.
Variance is random fluctuation from finite sampling. It can often be reduced by more samples, variance reduction, or a better proposal distribution.
Bias is a systematic shift. It can come from:
- sampling the wrong distribution;
- insufficient burn-in;
- a biased estimator;
- finite time-step or discretization error;
- using an approximate model;
- stopping an optimization based on noisy estimates.
Increasing reduces variance but does not automatically remove bias.
Quantum-Mechanics Uses
Section titled “Quantum-Mechanics Uses”Quantum mechanics uses Monte Carlo ideas in several distinct ways.
- Repeated projective or POVM measurements produce samples from Born probabilities. Estimating an expectation value from many shots is a Monte Carlo estimate of a measurement distribution.
- Variational Monte Carlo rewrites a variational energy as an expectation over configurations sampled from .
- Path-integral and worldline Monte Carlo sample configurations or paths in imaginary time when a positive sampling weight is available.
- Stochastic wavefunction and quantum-trajectory methods sample individual trajectories whose ensemble reproduces an open-system master equation.
These uses share probability tools but differ in physics and algorithms. The reusable probability facts are here; the detailed computational methods belong to dedicated computational and many-body pages. For the existing physics preview, see Variational Monte Carlo Preview.
Sign and Phase Problems
Section titled “Sign and Phase Problems”Monte Carlo works best when the target can be interpreted as a nonnegative probability density. Quantum calculations often produce oscillatory phases or positive and negative weights.
If an integral is written as
where is sampled and is a sign or phase factor, then the estimator may involve an average sign or phase. When that average becomes very small, the relative error can grow exponentially with system size, time, or inverse temperature.
This sign or phase problem is not a minor implementation nuisance. It can be the central obstruction in real-time path integrals, frustrated spin systems, and fermionic many-body calculations.
The Sign Problem Preview owns the many-body reweighting identity, free-energy scaling of the average phase, basis dependence, sign-free structures, and complexity qualifications.
Common Mistakes
Section titled “Common Mistakes”- Reporting a Monte Carlo number without an uncertainty estimate.
- Treating correlated Markov-chain samples as independent samples.
- Confusing stochastic error with systematic bias.
- Assuming scaling solves poor overlap or rare-event sampling.
- Forgetting support conditions in importance sampling.
- Trusting self-normalized weights without checking weight degeneracy.
- Ignoring burn-in, autocorrelation time, and random-seed reproducibility.
- Treating a sign problem as merely a need for more patience.
Cross-Links
Section titled “Cross-Links”- Random Variables
- Probability Densities
- Expectation Values
- Variance and Covariance
- Conditional Probability
- Gaussian Distributions
- Fisher Information
- Error Estimates
- Born Rule
- Variational Monte Carlo Preview
References
Section titled “References”- N. Metropolis and S. Ulam, “The Monte Carlo Method,” Journal of the American Statistical Association 44, 335–341, 1949.
- N. Metropolis, A. W. Rosenbluth, M. N. Rosenbluth, A. H. Teller, and E. Teller, “Equation of State Calculations by Fast Computing Machines,” Journal of Chemical Physics 21, 1087–1092, 1953.
- J. M. Hammersley and D. C. Handscomb, Monte Carlo Methods, Methuen, 1964.
- J. S. Liu, Monte Carlo Strategies in Scientific Computing, Springer, 2001.
- C. P. Robert and G. Casella, Monte Carlo Statistical Methods, 2nd ed., Springer, 2004.
- M. E. J. Newman and G. T. Barkema, Monte Carlo Methods in Statistical Physics, Oxford University Press, 1999.
- W. M. C. Foulkes, L. Mitas, R. J. Needs, and G. Rajagopal, “Quantum Monte Carlo simulations of solids,” Reviews of Modern Physics 73, 33–83, 2001.
Exercises
Section titled “Exercises”- Show that the sample mean is unbiased for .
Solution
For independent identically distributed samples ,
Linearity of expectation gives
- Derive the variance of the sample mean for independent samples.
Solution
If each has variance and the samples are independent, then
Using independence,
- A simulation has independent samples with sample standard deviation and . Estimate the standard error of the sample mean.
Solution
Use
Thus
- Prove the basic importance-sampling identity.
Solution
Assume wherever contributes. Then
The Monte Carlo estimator is the sample average of the random variable inside this expectation.
- A two-outcome quantum measurement gives outcome with Born probability . If independent shots are used to estimate by the observed frequency , what is ?
Solution
Each shot is a Bernoulli random variable with variance
The frequency is the sample mean of independent Bernoulli samples. Therefore
The standard error is