Probability and EstimationPart 3 of 5Intermediate · Updated July 31, 2026
Monte Carlo Simulation
Many integrals in estimation have no closed form. Grid-based quadrature handles them in one or two dimensions, but its cost grows exponentially with dimension. Monte Carlo estimation replaces the grid with random draws, whose error does not depend on dimension.
An integral is an expectation, estimated by a sample mean
The core idea is to write the integral as the expected value of a function under some distribution, then estimate that expectation by averaging the function over random draws. For
draw independent samples from and average:
The estimator is unbiased, for every , and by the law of large numbers it converges to as grows.
The error falls as one over root N in any dimension
The samples are independent, so the variance of the mean is the variance of one term divided by :
Each additional decimal digit of accuracy costs a hundred times more samples. In one dimension the trapezoid rule, with error in the spacing , achieves .
The dimension does not appear in , but it does for a grid. Covering a -dimensional cube at spacing takes points, so the trapezoid rule’s error becomes :
| dimension | trapezoid | Monte Carlo |
|---|---|---|
| 1 | ||
| 4 | ||
| 10 | ||
| 50 |
Below about four dimensions a grid is more accurate, deterministic, and controlled by a parameter the user sets. Above that, Monte Carlo converges faster, and in high dimension it is often the only feasible method.
Worked example: estimating π
Sample points uniformly in the unit square and count the fraction inside the quarter circle. Here is an indicator with mean , so and . The standard error of the estimate of is :
- : about
- : about
- : about
Four correct digits require on the order of a million samples. In this low-dimensional problem quadrature is far more efficient; the example illustrates the convergence rate, not the method’s advantage.
Importance sampling
With the rate fixed at , accuracy can be improved only by reducing . If most of the integrand’s contribution comes from a region that rarely visits, most draws from contribute little. Importance sampling draws instead from a distribution concentrated in that region and corrects for the substitution:
The estimator becomes a weighted average with weights . It remains unbiased for any that is non-zero wherever is non-zero.
The variance depends on . A proposal shaped like can reduce by orders of magnitude. A proposal with thinner tails than increases it: the weights grow without bound in the tails, a single sample can dominate the average, and the variance may be infinite even though individual runs appear stable. The usual diagnostic is the effective sample size,
If 10,000 samples give , almost all the weight lies on a few draws and the estimate has roughly the precision of forty independent samples.
Assumptions and limitations
- Monte Carlo is appropriate when the dimension is high, when the domain is too irregular to mesh, or when a process can be simulated but its density cannot be written down. These conditions arise in Bayesian inference, rendering, and physical and financial simulation.
- In low dimension a grid is usually better. A pair of nested one-dimensional integrals along two curves, for instance, is better handled by quadrature, which offers controllable accuracy and reproducible results.
- Importance sampling requires a proposal with tails at least as heavy as the target’s; otherwise its variance can be infinite.
- The method assumes that samples can be drawn from . A Bayesian posterior is usually known only up to a normalising constant, so this assumption fails.
Summary
- Any expectation can be estimated by a sample mean, without bias.
- The standard error is in every dimension, which is slow in low dimension and favourable in high dimension.
- Importance sampling lowers by sampling where the integrand matters and reweighting; the effective sample size measures how well it is working.
The next tutorial samples a posterior known only up to a constant, using importance sampling and a Markov chain method.