5.5 Monte Carlo integration
Source: Ideas from Computational Physics (Landau, Páez, Bordeianu), §5.5. Rewritten in original wording. Continues 5.4 Gaussian quadrature. Labs: 5.5b Monte Carlo integration labs.
Pond area by stone throwing
Imagine a pond inside a rectangular fence of known area . Throw stones uniformly at random into the box; count how many land in the water (). Walk the hit-fraction ratio, the pond-area estimator, and — pick the matching equation at each step.
No antiderivative, no mesh — only a uniform sampler and a membership test (“inside the pond?”). That is the Monte Carlo idea for integration: replace geometry by counting.
from a unit circle in a square
Put the unit disk inside the square of side (area ). The guide’s last two steps are the hit fraction and the factor-of-four estimator. With the chapter LCG and throws you typically land near — close enough to see the method, not a replacement for in production. The statistical error scales like : quadrupling the sample count halves the typical fluctuation.
Why Monte Carlo for integrals?
In one dimension, trapezoid, Simpson, and Gauss usually beat crude Monte Carlo for smooth . Monte Carlo shines when:
- the domain is awkward (irregular pond, complicated acceptance region);
- the dimension is large — a grid with points per axis needs evaluations, which explodes;
- you only need a rough answer with a transparent error bar .
The next lesson (§5.6) makes the mean-value form precise and shows the -independence of the law.
Error investigation: trap / Simpson / Gauss / MC
A standard calibration integral is
Run trapezoid, Simpson, Gauss–Legendre, and a mean-value Monte Carlo estimate at several , then plot versus . On that log–log plane a clean power law
appears as a straight segment with slope . Deterministic rules for smooth often show steep negative slopes (Simpson in , Gauss even steeper in for analytic integrands) until round-off flattens the floor — algorithms stop improving when floating-point noise dominates (the Fig. 5.5 idea). Monte Carlo’s slope is near ; it loses in 1D on this smooth problem, but that shallow slope does not get worse when grows.
Use the explorers below (and §5.6’s mean-value chart) to compare regimes rather than memorizing a single “best” rule.
Monte Carlo integration
1 / 3Stone-throwing estimates A_pond by…
Pick an answer to see if you are right.