An integral is just an average in disguise
In the earlier rungs you met quadrature: pin down an integral by sampling the integrand at carefully chosen nodes — trapezoidal points, Simpson's points, Gauss-Legendre points — and taking a clever weighted sum. Those rules are gloriously accurate in one dimension. Monte Carlo integration starts from a completely different instinct. It notices that an integral is secretly an average. The quantity (1/(b-a)) * integral of f over [a,b] is, by definition, the mean value of f across the interval. So instead of placing nodes by a grid, just sample x uniformly at random in [a,b], evaluate f there, and average. Multiply that average by the width (b-a) and you have an estimate of the integral.
Here is the tiny worked example to lock it in. To estimate the integral of f(x) = x^2 from 0 to 1 (the true answer is 1/3), draw N random points x_1, ..., x_N uniformly in [0,1], square each one, and average: the estimate is (1/N) * (x_1^2 + ... + x_N^2). With N = 4 random draws you might get something like 0.41; with N = 1000 you would typically land within a hundredth of 0.333. You did not need the antiderivative, you did not need a grid, you did not even need f to be smooth — you only needed to be able to evaluate f at a random point. That brutal simplicity is the whole appeal.
How big is the error? The 1/sqrt(N) law
Because the estimate is a random average, its accuracy is governed by the central limit theorem, also from your probability rung. The standard deviation of an average of N independent draws shrinks like sigma/sqrt(N), where sigma is the spread (standard deviation) of the single random value f(X). So the typical size of the Monte Carlo error is sigma/sqrt(N) — it falls off like O(1/sqrt(N)). That square root is the central, sobering fact of the whole method, and it is worth feeling in your bones.
Let the slowness sink in. To cut the error in half, you do not double N — you must quadruple it. To gain one more correct decimal digit (a factor of 10 in accuracy), you need 100 times as many samples. Go from N = 10^4 to N = 10^6 and your error improves only tenfold. Compared with the order-of-accuracy rungs you climbed earlier, where Simpson's rule was O(h^4) and a spectral method could be O(h^p) for huge p, O(1/sqrt(N)) is glacial. If Monte Carlo were only ever used on the one-dimensional integrals where Simpson's rule lives, it would be a bad joke.
true value of integral of x^2 on [0,1] = 0.33333... N estimate |error| ~ sigma/sqrt(N) 100 0.351 0.018 0.030 10,000 0.3356 0.0023 0.0030 1,000,000 0.33339 0.00006 0.00030 100x more samples -> ~10x smaller error (one extra digit) error ~ 1/sqrt(N): the rate, not the exact number, is the law
The killer feature: the error does not care about dimension
Now the twist that redeems everything. Look again at the error formula, sigma/sqrt(N): the number of dimensions d does not appear in it. Anywhere. The error of Monte Carlo integration is dimension-independent — it falls like O(1/sqrt(N)) whether you are integrating over a line, over a square, or over a 500-dimensional cube. This is not a minor convenience; it is the reason the method exists. Compare what happens to grid-based quadrature as dimension climbs.
Suppose you tile each axis with n points to get a tolerable grid. In one dimension that is n evaluations. In two dimensions you need a full n-by-n grid, so n^2 evaluations. In d dimensions you need n^d — and that explosion is the curse of dimensionality you met earlier. With a modest n = 100 and d = 10, a product grid demands 100^10 = 10^20 function evaluations: utterly impossible. Worse, the accuracy of those grid rules decays with dimension too, because each axis gets starved of points. Monte Carlo simply ignores this. Ten dimensions or ten thousand, it keeps grinding out O(1/sqrt(N)). The slow square root that looked embarrassing in 1D becomes a miracle in 1000D, where every deterministic rule has already collapsed.
Building the estimator, honestly
Let us assemble the recipe and be precise about each ingredient. To estimate the integral of f over a region of volume V, draw N points uniformly at random inside the region, average the f values, and multiply by V. The randomness comes from the pseudorandom number generator of guide 1 — and remember its honest caveat: those numbers are deterministic. Seed the generator the same way and you replay the exact same 'random' points, which is a feature, not a bug, because it makes your Monte Carlo run reproducible. To draw points from a region or distribution that is not a plain uniform box, you reach for the sampling machinery of guide 2 — inverse-transform and rejection sampling — to turn uniform draws into whatever shape you need.
- Decide what to estimate: the integral of f over a region with known volume V (or, more generally, the expected value of some quantity under a distribution).
- Draw N independent random points inside the region using your generator (uniform for a box; otherwise sample the distribution with the tools of guide 2).
- Evaluate f at each point and form the sample mean (1/N) * sum of f(x_i).
- Multiply the mean by V to get the integral estimate.
- Report an error bar too: estimate sigma from the same samples and quote sigma/sqrt(N). Never hand over a Monte Carlo number without it.
That last step is the mark of an honest practitioner. Monte Carlo hands you not just an estimate but a built-in error estimate, because the very samples you averaged also tell you their own spread sigma. You quote the result as estimate plus-or-minus sigma/sqrt(N) — usually a one-standard-deviation (about 68%) band, or 2*sigma/sqrt(N) for a roughly 95% band. This is a genuine strength over deterministic rules, where the error is real but invisible unless you do extra work. But hold two cautions. First, the error bar is itself a random estimate and can be misleading when sigma is large or the distribution is heavy-tailed, so it is a guide, not a guarantee. Second, like every numerical answer in this whole field, the result is approximate and lives in floating-point arithmetic; summing millions of tiny contributions can lose digits to round-off, so a careful implementation may use compensated summation.
Two honest dials: variance and the sequence of points
Stare at the error sigma/sqrt(N) and you see exactly two dials. One is N, the number of samples — but it sits under a square root, so brute-forcing N is expensive and quickly hits diminishing returns. The other is sigma, the variance of what you are averaging — and that is where the real leverage hides. If you can rewrite the same integral as the average of a quantity that varies less from point to point, sigma drops, and the error drops proportionally for free, with N untouched. Reducing sigma is the entire game of the next guide, variance reduction — importance sampling, control variates, stratified sampling — which can slash sigma by large factors and is often worth far more than throwing hardware at a bigger N.
There is also a sneakier way to beat the square root, and it is worth naming so the 1/sqrt(N) law does not feel like an iron prison. Quasi-Monte Carlo abandons true randomness and instead lays down a low-discrepancy sequence — points engineered to spread out far more evenly than random scatter, which tends to clump and leave gaps. For nice (smooth, not-too-high-dimensional) integrands this can converge nearly like O(1/N) rather than O(1/sqrt(N)) — almost a squared improvement. The honest catch: quasi-Monte Carlo is no longer truly random, so the clean central-limit error bar evaporates and its advantage fades as dimension climbs or the integrand turns rough. And looming over all of these is the wall you will hit when the distribution itself is too tangled to sample directly — the gateway to Markov-chain Monte Carlo, the final guide of this rung.