1001Ferramentas
🥧Calculators

π Estimation (Monte Carlo)

Estimate π by Monte Carlo: 4 × (points inside unit circle / total).

Estimating π by Monte Carlo

Throw n random points uniformly into the unit square [0,1]² and count how many fall inside the quarter unit circle (x² + y² ≤ 1). Since the quadrant has area π/4 and the square has area 1, the ratio k/n converges to π/4, so π ≈ 4·k/n. Convergence is slow — error scales as 1/√n. Example: 1,000 points → π with ~3% error; 1,000,000 points → ~0.1% error. The method was introduced by Stanislaw Ulam and John von Neumann at Los Alamos around 1946 for neutron-transport simulations during the Manhattan Project.

Applications

High-dimensional numerical integration (the only family that escapes the curse of dimensionality), physical simulation (neutron transport, lattice QCD), finance (option pricing via Black-Scholes-Monte-Carlo), reinforcement learning (MCTS in AlphaGo / AlphaZero) and Bayesian inference (MCMC — Markov Chain Monte Carlo).

FAQ

Why is convergence so slow? Standard error of a Monte Carlo estimator is σ/√n. To gain one decimal place of precision you need 100× more samples.

Why use it if it's slow? In high dimensions deterministic quadratures cost exponentially in dim; Monte Carlo stays at 1/√n regardless of dimension — the only practical option above ~6–8 dimensions.

How can I reduce variance? Importance sampling, stratified sampling, antithetic variables, control variates, and quasi-Monte Carlo (Sobol, Halton) which achieves nearly 1/n.

Related Tools