Numerical integration · CMNA Laboratory

Estimate area by throwing points at the problem.

Give R an arbitrary integrand, then watch a random sample cloud turn into a numerical estimate as n grows.

Randomness replaces geometry.

CMNA's one-dimensional Monte Carlo integrator samples x uniformly over the interval, evaluates f(x), and multiplies the sample mean by the interval width. The estimate wanders, then settles statistically rather than deterministically.

Bring your own integrand

Let R roll the dice.

Write any vectorized R function, choose bounds, sample count, and seed, then play the estimate as the sample grows.

RuntimePreparing R…
RDefine f(x)

samples nrunning estimate
Book§5.4.3 · Monte Carlo Methods · p. 151Book details
CMNA packagemcint
TeachingInstructor notes and chapter contextOpen teaching material
Numerical ZooWorked problems