SimuVeda

Mathematics · Simulator 050

Monte Carlo Estimation

Scatter random points over a square and count how many land inside a shape. That fraction estimates the shape's area. Use it to estimate π, or the area under a curve, and see how slowly but surely the estimate improves as the points pile up.

How the model works

If points are uniform over a square of area A, the fraction landing in a region estimates that region's area divided by A. For a quarter circle of radius 1 inside the unit square, the area is π/4, so

π ≈ 4 × (points inside) / (total points)

Each point is a yes/no trial with probability p, so the estimate's standard error is √(p(1 − p)/n). It shrinks like 1/√n: 100 times more points give only 10 times more accuracy. The log–log error chart shows this slope of −½.

Monte Carlo methods are slow for simple 2-D areas, but they handle high-dimensional problems where grid methods are hopeless, from particle physics to finance. A seeded generator makes runs reproducible; change the seed to see run-to-run scatter.

Pseudo-random numbers (Mulberry32) are not truly random but are fine for this purpose.

Guided experiments

  1. Estimate π. Throw 10 000 points. Prediction: typically within ±0.016 of π (one standard error ≈ 4·√(0.785 × 0.215/10000) ≈ 0.016).
  2. Error slope. Watch the log–log error chart up to 100 000 points. Prediction: the error falls along the −½ guide line, with random wiggles.
  3. Area under a curve. y = x² on [0, 1]. Prediction: the fraction below the curve tends to 1/3.

Challenge

How many random points would you need to estimate π to about ±0.001 (one standard error)?

Reveal the explanation

Standard error ≈ 4√(p(1 − p)/n) with p = π/4, so 4√(0.1686/n) = 0.001, which gives n ≈ 2.7 million. Each extra correct digit costs 100 times more points.

References

  • Metropolis & Ulam (1949), “The Monte Carlo method”, Journal of the American Statistical Association 44: 335–341.
  • OpenStax, Introductory Statistics, ch. 7 (standard error).