Hexa Scholar

Monte Carlo integration: how many samples?

Gold probes stand at scattered locations on a wooden terrain in a cream tray, beside a navy bowl of spare probes.
Scattered probes on a terrain stand for evaluating a function at sampled locations.

The question

Choose a sample budget, then inspect the estimates.

  1. 1 SeeChoose a budget before sampling.
  2. 2 TryCompare costs as dimension grows.
  3. 3 ProveDerive the error scale.
  4. 4 ApplyPlan and interpret an integral estimate.
Before you start · 3 quick checks on averages, uniform sampling, and spread

Two ideas before you start

2 ideas

A random location gives a height

A parabola and a vertical probe at the selected horizontal location.

Choose a location to read its height. Random integration samples the horizontal location; the function determines the height.

Exact definition

For a finite interval with \(a\lt b\), a uniform draw \(U\) has density \(1/(b-a)\) on the interval and zero outside. Subintervals of the same length have the same probability. A height \(Y=f(U)\) need not have a uniform distribution.

The buttons are chosen locations, not random draws. The simulator below instead uses independent uniform locations to estimate an integral. In a box in higher dimensions, each coordinate is uniform on its own interval, independently of the other coordinates.

Turn heights into an average

Bars show a short list of heights; a dashed line shows their average.

Switch lists. Multiplying the average height by the domain's width or volume produces an integral estimate.

Exact definition

Let \(D\) be a box of finite positive volume \(V\). For iid uniform points \(U_i\) in \(D\), define

\[\widehat I_n=\frac Vn\sum_{i=1}^n f(U_i).\]

Here iid means independent and identically distributed. The target is the fixed integral \(I=\int_D f(u)\,du\). Assume \(f\) is measurable and square-integrable on \(D\); then its uniform-sample mean and variance exist. These illustrative lists are arithmetic examples, separate from the simulator.

Refresher: what varies between runs?

The integral and sampling rule stay fixed. The random locations change, so the estimated integral changes. The standard deviation of those estimates across repeated samples is called their standard error. The absolute error of one estimate is its distance from the true integral. Those quantities describe different things.

Numerical integration constructs deterministic rules from a grid. Here no smoothness is assumed; the function only needs to be square-integrable. We choose an example with a known integral to measure the realized error; in an actual unknown-integral problem that comparison is unavailable.

1 See

Choose the sample budget

Keep the function and sampling distribution fixed. The target concerns the spread across repeated samples. It does not ask for a promise about the next run's absolute error.

2 Try

Add coordinates

A product grid chooses every combination of coordinate locations. Predict its evaluation cost before opening the comparison. This question counts points; it does not compare the accuracy of the two methods.

3 Prove

Derive the scale of the error

Theorem

Let \(D\) be a box with finite volume \(V\gt0\). Let \(f\) be measurable and square-integrable, and let \(U_i\) be iid uniform points in \(D\). Put \(Y_i=f(U_i)\), \(I=\int_D f\), and \(\sigma^2=\operatorname{Var}(Y_i)\). For the builder assume \(0\lt\sigma^2\lt\infty\) and an integer \(n\ge2\) fixed before sampling. Then

\[\begin{aligned}E[\widehat I_n]&=I,\\\operatorname{Var}(\widehat I_n)&=V^2\sigma^2/n,\\\operatorname{RMSE}(\widehat I_n)&=V\sigma/\sqrt n.\end{aligned}\]

RMSE means the square root of the expected squared error relative to the fixed integral. It equals the standard error here because the estimator is unbiased. No normal approximation is needed for these identities.

Use the uniform density to identify the target. Then use independence to add variances and square the multiplier when scaling a random variable. Build the steps or open the read-through.

4 Apply

Plan an estimate and report its uncertainty

Use what you found above. Each problem has hints and a worked solution. Enter a decimal without units. Keep extra precision until the final answer and use the tolerance stated in the question.

The same averaging idea appears in Monte Carlo pricing, where a model specifies the sampling distribution and a discounted payoff is the quantity averaged. That lesson adds the financial assumptions needed to interpret the expectation as a price.

Key point Carry the domain volume through both the estimate and its SE. State whether a sample budget uses a known spread or a pilot estimate, and report a sampling interval as an approximation when its coverage relies on a limit theorem.
Level Introductory undergraduatePrerequisites Integrals, averages, variance; uniform sampling refreshed aboveTime About 35 min

Further reading