Monte Carlo Simulator
Estimate quantities with Monte Carlo methods — random sampling instead of exact calculation. Three classic experiments: estimate π by throwing darts at a unit square (the fraction inside a quarter circle × 4), estimate π again via Buffon's needle (dropping needles on a lined floor), and estimate a definite integral ∫ₐᵇ f(x) dx by averaging the function over random points. Each run shows the sampled picture, the running estimate, the error against the true value, and a convergence chart. Uses a seeded PRNG so runs are reproducible. Everything runs locally in your browser.
Convergence (estimate vs samples)
Monte Carlo methods estimate a quantity by averaging many random samples — trading exactness for simplicity, with error shrinking as 1/√n. To estimate π, throw darts uniformly into a unit square: the fraction landing in the inscribed quarter circle equals π/4, so π ≈ 4·(inside/total). Buffon's needle drops needles of length L on a floor ruled with lines spaced D: the crossing probability is 2L/(πD), so π ≈ 2L·n/(D·crossings). A definite integral ∫ₐᵇ f(x) dx is estimated by averaging f over uniform random points in [a,b] and multiplying by (b−a), with a standard error of (b−a)·σ/√n. f(x) may use Math functions (e.g. Math.sin(x), x*x, Math.exp(-x*x)). The PRNG is a seeded mulberry32 so results reproduce. Pairs with the Normal Distribution and Bayes' Theorem tools. Everything runs locally — nothing leaves your browser.