SimuVeda/ Mathematics

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.

Class 6–8Class 9–10Class 11–12Class 8 Maths: data handling (chance and probability); Class 10 Maths: Probability (estimating π with random points)

Experiments 0 of 0 Challenge not tried

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).

Related simulators

Worked example

Estimate π with 1 000 points. Suppose 790 of 1 000 random points in the unit square land inside the quarter circle.

Estimate: π ≈ 4 × 790 / 1000 = 3.16.

How good is it? The standard error is 4 × √(p(1 − p) / n) with p ≈ π/4 ≈ 0.785: 4 × √(0.785 × 0.215 / 1000) ≈ 0.052. The true value 3.1416 is within one standard error of 3.16, so this is a normal result.

To halve the error you need 4 times as many points (4 000), because the error shrinks like 1/√n. For 10 times less error you need 100 times more points.

Common questions

What is a Monte Carlo simulation?

A way to compute a number with random samples. You run many random trials and use the fraction or average of the results as the estimate, like counting how many random points fall inside a circle to get π.

How many samples does a Monte Carlo estimate need?

The error falls like 1/√n. Going from 100 to 10 000 points makes the error about 10 times smaller, so pick n from the accuracy you need.

Why use Monte Carlo if it converges slowly?

Its error rate does not depend on the number of dimensions. Grid methods become impossible in 10 or 100 dimensions, which is why physics, finance and risk models use random sampling.

Keyboard shortcuts

Space
Play or pause
S
Step
R
Reset
F
Full screen
?
Show this list