Random sampling for estimation and numerical integration — run experiments and watch confidence intervals accumulate
Samples per run
● inside circle✕ outside circle
Total samples
—
Inside circle
—
Estimate of π/4
—
Estimate of π
—
True π/4
0.78539816339744…
True π
3.14159265358979…
Each "dart" lands at a uniform random point in the square. The fraction landing inside the inscribed circle estimates π/4. Run many experiments to watch 95% confidence intervals accumulate — nearly all should capture the dashed true value.
Experiment History — 95% Confidence Intervals for π/4
Borel’s Law of Large Numbers guarantees convergence — the 95% CI will capture π ≈ 95% of the time.
FunctionSamples
Random rectangles of width L/M and height f(xi)
Samples (M)
—
Domain length (L)
—
Rect. width (L/M)
—
MC Estimate
—
True Integral
—
Relative Error
—
① Connection: this function's integral equals π/4 — the same quantity estimated by dartboard sampling on Tab ①. Both are Monte Carlo estimates of the same number!
Experiment History — 95% Confidence Intervals for ∫f(x)dx
Random Riemann Rectangles — as M grows, width L/M shrinks
Each rectangle has width L/M and height f(xi) at a random xi ~ U(a, b). As M → ∞, overlaps and gaps average out and the estimate converges to the true integral. The formula (L/M)·Σf(xi) is a Riemann sum with random partition points. This animation always uses f(x) = sin(x) on [0, π].