Mathematical LaboratoriesProbability & statistical physicsRichard Kraaij · TU Delft

INTERACTIVE LABORATORY / 01

Random points.
Reliable answers.

Estimate π, integrate your own function, and discover how random sampling leads to predictable answers.

01

Experiment settings


Ready. Start a simulation or add one sample.

02

The random experiment

QUARTER CIRCLE

Hit or miss

Draw X and Y independently.

Add one sample to follow the same draw in both panels.

How the samples are generated

Each point is uniformly sampled in the unit square. Green points are inside the quarter circle.

Samples n0
Reference π—
Estimate of π—
Estimated SE—
Average-height estimate—Estimated SE: —
Hit-or-miss estimate—Estimated SE: —

Both estimates use the same n horizontal draws. Averaging heights removes the extra randomness of Y.

03

One run · The law of large numbers

Average heightsHit or missReference

Solid line: running estimate. Dashed line: reference. For π, the second solid line is the average-height estimator.

04

Many runs · Sampling distribution

Run independent repetitions to build the distribution of estimates at a fixed sample size.

Runs per estimator: 0Hit or miss · mean: — · SD: —Average heights · mean: — · SD: —

Teal bars: hit-or-miss density. Orange outline: average-height density. Both use the same bins and axes; the vertical dashed line marks the reference.

UNDERSTANDING THE EXPERIMENT

Numerical integration as expectation

One realization

If X is uniform on [a, b], the average of (b−a)f(X) converges to the integral whenever f is integrable. Watch a running estimate stabilize—though temporary deviations remain possible.

Independent repetitions

Run the experiment again from new independent random draws. The spread of the estimates reveals sampling uncertainty. With finite variance, it usually decreases like 1/√n.

Why compare the methods?

For a fixed X, the chance that Y lies below the graph is (f(X)−L)/(U−L). Averaging over Y turns the hit-or-miss contribution into (b−a)f(X). Removing this extra randomness reduces variance. It does not guarantee that the average-height estimate is closer to the reference in every individual run.

The displayed reference for entered functions uses numerical quadrature, not symbolic integration. Nonintegrable or singular functions may be unsuitable for this laboratory. Every computation runs locally in your browser; no results are collected.