INTERACTIVE LABORATORY / 01
Random points.
Reliable answers.
Estimate π, integrate your own function, and discover how random sampling leads to predictable answers.
Experiment settings
Try exp(-x^2), sin(alpha*x), or x^3 - beta*x. Use explicit multiplication (*).
The vertical bounds must contain the entire function. Samples are checked, but the plotted grid cannot prove a bound.
Ready. Start a simulation or add one sample.
The random experiment
QUARTER CIRCLEEach point is uniformly sampled in the unit square. Green points are inside the quarter circle.
The second estimator conditions on the horizontal coordinate, reducing the variance while estimating the same π.
One run · The law of large numbers
Solid line: running estimate. Dashed line: reference. For π, the second solid line is the average-height estimator.
Many runs · Sampling distribution
Run independent repetitions to build the distribution of estimates at a fixed sample size.
Bars are empirical density. The optional bell curve uses the observed mean and SD and is only a normal approximation.
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.
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.