Fundamentals / Numerical mathematics / Approximation and quadrature / Function approximation and numerical integration

Spend random samples where they reduce uncertainty

A Monte Carlo estimate can be unbiased and still too noisy to be useful. Derive control variates, allocate a fixed budget across strata, and distinguish variance reduction from an underestimated standard error.

Subtract a fluctuation with an independently known mean

To estimate \(I=\mathbb E[f(X)]\), suppose evaluating \(f(X)\) also supplies a cheap correlated quantity \(g(X)\) with known exact mean \(\mu_g\). For any fixed coefficient \(\beta\), \(Y=f(X)-\beta[g(X)-\mu_g]\) has the same mean \(I\). Its variance is \(V_f-2\beta C_{fg}+\beta^2V_g\). Differentiating gives optimum \(\beta_*=C_{fg}/V_g\) if \(V_g>0\) and minimum \(V_f(1-\rho_{fg}^2)\). For a crude physical surrogate it is accuracy of its fluctuations, not its absolute scale, that matters. A negatively correlated surrogate can also reduce variance by a negative coefficient. A constant control carries no information and should not be divided by zero variance.

As an exact example take \(X\sim U[0,1]\), \(f=X^2\), \(g=X\). We know \(\mu_g=1/2\) and seek \(I=1/3\). Direct moments give

\[V_f=1/5-1/9=4/45,\ V_g=1/12,\ C=1/4-1/6=1/12.\]

Hence \(\beta_*=1\) and residual variance \(4/45-1/12=1/180\), sixteen times smaller than the original. At the same sample count the standard deviation falls by four. Each controlled sample \(X^2-X+1/2\) is not equal to the true answer, but it fluctuates much less. An independent pilot run can estimate \(\beta\) for unknown covariances. Reusing the same small sample to optimise \(\beta\) and estimate the mean can introduce finite-sample bias and overstate achieved variance reduction, especially when many controls are fitted.

Partition the input space and allocate observations

Divide the domain into disjoint strata with known probabilities \(w_j\), then draw \(n_j\) independent observations within each. The stratified estimator is \(\hat I=\sum_j w_j\bar f_j\) with variance \(\sum_jw_j^2\sigma_j^2/n_j\), where \(\sigma_j^2\) is the conditional variance. Correct weighting is crucial: the allocation probabilities need not equal the target distribution's stratum probabilities. At a fixed total sample count \(N=\sum n_j\), differentiating with a Lagrange multiplier gives \(n_j\propto w_j\sigma_j\), known as Neyman allocation. For unequal sample costs \(c_j\) under fixed \(\sum c_j n_j\), the corresponding optimum is \(n_j\propto w_j\sigma_j/\sqrt{c_j}\). Pilot uncertainty and minimum counts per stratum matter before rounding to feasible integers.

For two equal-probability strata with conditional standard deviations 1 and 4, \(N=100\) calls yields optimal counts 20 and 80. The variance becomes \((1/4)(1/20+16/80)=0.0625\), compared with \(0.085\) from 50 each. The difference is material but smaller than one might guess from the 4:1 standard deviation ratio. Overallocating all observations to the difficult stratum would leave the other conditional mean unidentified. A deterministic stratum whose mean is known separately can be removed; one whose variance merely looked zero in a tiny pilot may still need independent sampling. For rare heavy-tail excursions, a naive pilot can miss the very fluctuations it was intended to characterise.

Choose an antithetic pair with a justified covariance

For symmetric \(U\sim U[0,1]\), both \(U\) and \(1-U\) have the target distribution. The pair average \(Z=[f(U)+f(1-U)]/2\) is unbiased. Its variance is \([V_f+\operatorname{cov}(f(U),f(1-U))]/2\). With the same two function evaluations, two independent samples would have variance \(V_f/2\). Antithetic pairing therefore helps exactly when the paired function values are negatively correlated, as with a monotone function over this scalar interval. If \(f(U)=f(1-U)\) the pair is redundant; the method then doubles cost per independent value. Compute standard errors across independent pairs, not by treating both values inside each pair as independent calls.

For \(f=X^2\), \(Z=X^2-X+1/2\), algebraically the same controlled random variable encountered above. Its variance is \(1/180\) per pair and it costs two evaluations. The linear control cost only one expensive \(f\) evaluation when \(g=X\) was nearly free. The two methods yield identical random fluctuations per independent draw of \(X\) here, but different error per unit computation. Comparing only the algorithm's reported sample count without accounting for pairs, pilot runs and surrogate evaluations can reverse a practical recommendation.

When does the control increase the noise?

Draw X uniformly on the unit interval and estimate the mean of X². The known mean of X is one half. Compare the standard errors at coefficients zero, one and three. Use the graph to find how many direct samples match the uncertainty of 32 optimally controlled samples, then confirm the answer from the exact variance ratio.

Tutorial · verify variance and bias separately

Budget calls with a measured correlation

A model response has standard deviation 6 and a validated fixed-coefficient control has correlation 0.95. Estimate calls for standard error 0.10 with and without control, neglecting control cost.

Work through the solution

Plain sampling requires \(6^2/0.1^2=3600\) independent calls. The controlled variance is \(36(1-0.95^2)=3.51\), requiring 351 independent calls. These counts assume the reported correlation and optimal coefficient apply to the production distribution. Validate with held-out paired observations. A mistaken known control mean introduces bias \(\beta(\mu_{\rm used}-\mu_{\rm true})\), which averaging more calls cannot remove.

Find the cost-aware allocation

Two equal-probability strata have standard deviations 1 and 4. Calls in the second cost four times those in the first. Allocate 180 cost units, measuring cheap calls in units of one.

Work through the solution

The optimum ratio \(n_2/n_1=(4/\sqrt4)/(1/\sqrt1)=2\). With \(n_1+4n_2=180\) this gives

\[n_1=20,n_2=40.\]

Their variance is

\[(1/4)(1/20+16/40)=0.1125.\]

Assigning half the calls to each would instead permit 36 and 36 with variance about 0.118. Assigning half the budget to each gives a different allocation again. Specify the constrained physical resource before quoting an optimum.

Identify an antithetic failure and repair the error estimate

For \(f(x)=(x-1/2)^2\), an analyst generates 100 independent antithetic pairs but computes an ordinary sample error as though all 200 values were independent. What is wrong?

Work through the solution

Each pair consists of identical function values. There are only 100 independent observations of this response; the variance of the paired estimator is \(V_f/100\), whereas the false independent count suggests \(V_f/200\). Estimate uncertainty from the variance of the 100 pair averages or use 200 genuinely independent calls if possible. Here the pairing has no cancellation because the function is symmetric under precisely the transformation used to generate the second member.

Further reading