Monte Carlo Explorer
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
Why does dartboard sampling estimate π?
Area of square:(2r)² = 4r²
Area of circle:πr²
Pr(dart inside):πr² / 4r² = π/4
By LLN as N → ∞:(# inside) / N  →  π/4
Therefore: π ≈ 4 × (# inside circle) / (# total samples)
Borel’s Law of Large Numbers guarantees convergence — the 95% CI will capture π ≈ 95% of the time.
Function Samples
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, π].
Loading…