Chance & simulation

Monte Carlo Variance Reduction Lab

Estimates the integral of one of four fixed functions on 0 to 1 (an exponential, a tilted hump, a hockey stick or an event share) five ways that each spend the same N evaluations, repeated 40 times on one seeded stream: plain sampling, antithetic pairs, a control variate with an estimated or chosen coefficient, and one draw per stratum. Every exact mean and variance is a closed form, shown beside the spread of the 40 estimates, with the variance ratios against plain sampling, the narrowest method, interval coverage, the control's spread against its coefficient and the exact variance against N. Five scored challenges are included. For learning variance reduction in Monte Carlo integration.

Last updated

Calculator overview

Inputs and outputs

This summary comes from the calculator's published input and output contract.

Inputs

Function (required)
About this input

The function g on 0 to 1 whose integral every method estimates: Exponential e^(a u), Tilted hump 4u(1 - u) + t u, Hockey stick max(u - K, 0) or Event share (1 when u is below P%, else 0). Chosen with the tabs over the function plot.

Default Exponential Allowed Exponential, Tilted hump, Hockey stick, Event share
Hump tilt t (required) Conditional
About this input

t, the tilt of the hump 4u(1 - u) + t u, from 0 to 2; 0 is the symmetric hump. Shown and used for Tilted hump only.

Default 0 Range 0 to 2
Your prediction (required)
About this input

Challenges 1 and 5: Not yet predicted, Plain, Antithetic pairs or Control variate. In challenges 1 and 5 the estimates stay hidden until you predict or choose; outside challenges 1 and 5 it changes nothing.

Default Not yet predicted Allowed Not yet predicted, Plain, Antithetic pairs, Control variate
Kink position K (required) Conditional
About this input

K, the kink position of the hockey stick max(u - K, 0), from 0 to 0.9; 0 is the straight line g(u) = u. Shown and used for Hockey stick only.

Default 0.5 Range 0 to 0.9
Seed (required)
About this input

The seed of the random stream, a whole number from 1 to 2147483646; the same seed always gives the same 40 repeats, and every method uses the same draws.

Default 2026 Range 1 to 2147483646
Your control coefficient (required)
About this input

Your coefficient beta for the control variate gbar - beta (ubar - 1/2), from -10 to 50; 0 gives plain sampling, and the best coefficient gives the smallest spread.

Default 1 Range -10 to 50
Challenge (required)
About this input

Selects a challenge: 0 for none, 1 to 5 for a predefined challenge, which fixes the settings except the input it leaves to you.

Default 0 Range 0 to 5
Evaluations N (required)
About this input

N, the evaluations of the function each estimate may spend, a multiple of 8 from 8 to 64 (antithetic pairs use N/2 pairs). A larger N extends each repeat's sample and keeps the first draws.

Default 16 Range 8 to 64
Exponential rate a (required) Conditional
About this input

a, the rate of the exponential function e^(a u), from 0.5 to 4. Shown and used for Exponential only.

Default 1 Range 0.5 to 4
Event share P (whole percent) (required) Conditional
About this input

P, the event share: g(u) is 1 when u is below P/100, else 0; a whole number from 1 to 99. Shown and used for Event share only.

Default 30 Range 1 to 99

Outputs

Lane axis, high end
About this output

The high end of the lanes' axis: the exact value plus 4.2 exact plain standard deviations. Blank when the inputs are not valid.

No unit declared
Function formula
About this output

The formula of the function used, for the plot's legend. Blank when the inputs are not valid.

No unit declared
Function used
About this output

The function used (a challenge sets its own). Blank when the inputs are not valid.

No unit declared
Lane axis, low end
About this output

The low end of the lanes' axis: the exact value minus 4.2 exact plain standard deviations. Blank when the inputs are not valid.

No unit declared
Mean 95% half-width, plain
About this output

The mean half-width of the 40 plain 95% intervals. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Mean 95% half-width, control variate
About this output

The mean half-width of the 40 control-variate 95% intervals. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Mean 95% half-width, antithetic pairs
About this output

The mean half-width of the 40 antithetic 95% intervals. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Exact SD, your coefficient
About this output

The exact standard deviation of the control estimate with your coefficient. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Exact SD, stratified
About this output

The exact standard deviation of the stratified estimate (one draw in each of N equal strata). Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Exact SD, plain
About this output

The exact standard deviation of the plain estimate at N, the square root of the function's variance over N. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Exponential rate used
About this output

The exponential rate used. Blank for another function and when the inputs are not valid.

No unit declared
The function g at u = 0, 0.01, ..., 1; the area under it is the exact value
About this output

The function at u = 0, 0.01, ..., 1 (101 rows): u and g(u). The area under the curve is the exact value.

No unit declared
Hump tilt used
About this output

The hump tilt used. Blank for another function and when the inputs are not valid.

No unit declared
The first repeat's N evaluation points: each draw, its mirror (first N/2 rows) and the stratified point of its row
About this output

The first repeat's N evaluation points (rows i = 1 to N; the rows past N are blank): the draw u and g(u), its mirror 1 - u and g(1 - u) in the first N/2 rows, and the stratified point ((i - 1) + u)/N with its g.

No unit declared
The exact variance of each method at N = 8, 16, ..., 64 evaluations
About this output

The exact variance of plain sampling, antithetic pairs, the control variate (best coefficient) and stratified sampling at N = 8, 16, ..., 64 evaluations (8 rows). The variance columns are blank while challenge 1 or 5 awaits a prediction, or while challenge 2 is active and not met.

No unit declared
Kink position used
About this output

The kink position used. Blank for another function and when the inputs are not valid.

No unit declared
Seed used
About this output

The seed used. Blank when the inputs are not valid.

No unit declared
Variance ratio, antithetic pairs
About this output

The exact plain variance over the exact antithetic variance; above 1 means tighter than plain sampling. Blank when the antithetic variance is zero (no spread), when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Variance ratio, your coefficient
About this output

The exact plain variance over the exact variance with your coefficient. Blank when that variance is zero, when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Variance ratio, stratified
About this output

The exact plain variance over the exact stratified variance. Blank when that variance is zero, when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Variance ratio, control variate
About this output

The exact plain variance over the exact control-variate variance at the best coefficient. Blank when that variance is zero, when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Model version
About this output

The model version.

No unit declared
Model Status
About this output

NOT VALID with the reason when an input cannot be used; CHECK when some of the 200 estimates fall outside the drawn range (they are drawn at its ends and counted); otherwise OK.

No unit declared
The five methods side by side
About this output

The five methods side by side (5 rows): the name, the evaluations, the mean, empirical and exact standard deviations, the empirical and exact variance ratios against plain, the exact variance times N, and for plain, antithetic and control the mean interval half-width and the intervals covering the exact value; the last column counts the estimates outside the drawn range. Columns 3 to 11 are blank while challenge 1 or 5 awaits a prediction.

No unit declared
Formula module versions
About this output

The formula modules the model is built from, with their versions.

No unit declared
The 40 repeats: each method's estimate and the lane bin it falls in (1 to 21; bin 11 is centred on the exact value)
About this output

The 40 repeats (rows): the repeat number, each method's estimate (plain, antithetic pairs, control variate, your coefficient, stratified) and the lane bin each falls in (1 to 21; bin 11 is centred on the exact value, and an estimate beyond the drawn range is in an end bin). The estimate and bin columns are blank while challenge 1 or 5 awaits a prediction.

No unit declared
Estimates outside the drawn range
About this output

How many of the 200 estimates (40 for each of the five methods) fall outside the drawn range of the exact value plus or minus 4.2 plain standard deviations. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Narrowest of plain, antithetic and control
About this output

Plain, Antithetic pairs or Control variate: the one of these three with the smallest exact variance at N, or Tie when no one is smaller than both others by more than a billionth of the plain variance. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Correlation of g(u) and its mirror
About this output

The exact correlation of g(U) and g(1 - U); negative values make antithetic pairs help. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Your coefficient used
About this output

Your control coefficient used. Blank when the inputs are not valid.

No unit declared
Challenge result
About this output

No challenge selected, MET or NOT MET.

No unit declared
Correlation of g(u) and u
About this output

The exact correlation of g(U) and U (clipped to -1 to 1); the control removes its square's share of the variance. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Intervals covering the exact value, plain
About this output

How many of the 40 plain 95% normal-approximation intervals contain the exact value (0 to 40). Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Intervals covering the exact value, control variate
About this output

How many of the 40 control-variate 95% intervals contain the exact value (0 to 40); the interval is optimistic at small N. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Intervals covering the exact value, antithetic pairs
About this output

How many of the 40 antithetic 95% intervals contain the exact value (0 to 40). Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Mean estimated coefficient
About this output

The mean of the 40 coefficients estimated in each repeat by least squares on its own draws. Blank when not valid, while challenge 1 or 5 awaits a prediction, or while challenge 4 is active and not met.

No unit declared
The exact SD of the control estimate against the coefficient (its lowest point is the best coefficient)
About this output

The exact standard deviation of the control estimate against the coefficient, at 41 coefficients spread evenly around the best one (row 21); the curve meets plain sampling at coefficient 0. Blank while challenge 1 or 5 awaits a prediction.

No unit declared
Best coefficient
About this output

The best control coefficient, 12 times the covariance of g(U) and U; the lowest point of the coefficient curve. Blank when the inputs are not valid or while challenge 4 is active and not met.

No unit declared
Challenge feedback
About this output

Feedback on the selected challenge: the prediction prompt (challenges 1 and 5), the met text or the not-met hint (blank with none).

No unit declared
Challenge score
About this output

The challenge score: 100 when met, else 0.

No unit declared
Challenge: the value scored
About this output

The value the selected challenge scores: the narrowest method's code 1 to 3 (1, blank for a tie), the antithetic SD at N over the plain SD at 64 (2), the exact variance ratio of antithetic pairs at the tilt (3), how far your coefficient's variance is above the best, as a percentage (4), or the largest distance of the chosen method's 40 estimates from the exact value (5, blank with no choice); blank with none, when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Challenge goal
About this output

The goal of the selected challenge (blank with none).

No unit declared
Evaluations used
About this output

The evaluations each estimate spends. Blank when the inputs are not valid.

No unit declared
The 21 lane bins of 0.4 exact plain SD around the exact value, and how many of each method's 40 estimates fall in each
About this output

The 21 lane bins (rows): the low and high edge of each bin (0.4 exact plain standard deviations wide, bin 11 centred on the exact value) and how many of each method's 40 estimates fall in it. The count columns are blank while challenge 1 or 5 awaits a prediction.

No unit declared
Spread of the 40 estimates, your coefficient
About this output

The standard deviation of the 40 control estimates with your coefficient. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Event share used
About this output

The event share used, a whole number from 1 to 99. Blank for another function and when the inputs are not valid.

No unit declared
Exact SD, control variate (best coefficient)
About this output

The exact standard deviation of the control-variate estimate at the best coefficient (the large-N limit of the estimated-coefficient lane). Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Exact SD, antithetic pairs
About this output

The exact standard deviation of the antithetic-pairs estimate at N. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Exact value of the integral
About this output

theta, the exact integral of the function on 0 to 1, from its closed form. Blank when the inputs are not valid.

No unit declared
Empirical variance ratio, control variate
About this output

The empirical variance of the 40 plain estimates over that of the 40 control-variate estimates. Blank when either lane has no spread, when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Empirical variance ratio, antithetic pairs
About this output

The empirical variance of the 40 plain estimates over that of the 40 antithetic estimates. Blank when either lane has no spread, when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Critical value z
About this output

z, the critical value of the 95% normal-approximation intervals. Blank when the inputs are not valid.

No unit declared
Spread of the 40 estimates, antithetic pairs
About this output

The standard deviation of the 40 antithetic-pairs estimates. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Spread of the 40 estimates, stratified
About this output

The standard deviation of the 40 stratified estimates. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Spread of the 40 estimates, plain
About this output

The standard deviation of the 40 plain estimates (divisor 39). Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
Spread of the 40 estimates, control variate
About this output

The standard deviation of the 40 control-variate estimates with the coefficient estimated in each repeat. Blank when not valid or while challenge 1 or 5 awaits a prediction.

No unit declared
This page is provided by LogicCommons for informational purposes only. Results are analysis outputs computed from the inputs you supply and are not professional advice. Verify all inputs and results independently.

LogicCommons is in beta. If a result, label, or reference looks wrong, tell us here; we read every message.

Methodology

Purpose and model boundary

This lab estimates one number, θ, the integral of a fixed function g over 0 to 1, by sampling, and compares five ways of doing it that all spend the same N evaluations of g: plain sampling, antithetic (mirror) pairs, a control variate with a coefficient estimated from the draws, the same control with a coefficient you choose, and stratified sampling with one draw in each of N equal strata. Each method is repeated 40 times on one seeded random stream, so you see the spread of its estimates, not one lucky run. The function is one of four families with one shape setting each: an exponential, a tilted hump, a hockey stick and an event share. Because every exact mean and variance of these functions has a closed form, the exact spread of each method is always shown beside the spread of its 40 estimates. Five scored challenges use the same model.

It is a lab for learning why some estimators are tighter than others at the same cost: when a mirror twin helps and when it hurts, how a control variate removes the straight-line part of a function, how its coefficient trades off, and how stratification and the number of evaluations change the spread. It is not a general integration or simulation tool. It accepts no typed formula, works in one dimension only, and its generator is meant for repeatable classroom experiments.

The model is the calculation authority. The page sends the values you set to the model and draws only what it returns: the function curve and its shaded area, the first repeat's evaluation points and their mirror twins, the strata, the five lanes of estimates and their exact-value lines and spread bars, the coefficient curve and the variance-against-N chart. The page computes no random number, estimate, bin, variance or ratio itself.

Inputs and units

Every value in the lab is a pure number: a draw u lies between 0 and 1, g(u) and every estimate are numbers, and the cost is a count of evaluations. Every input is required.

Input Meaning and unit
Function Exponential, Tilted hump, Hockey stick or Event share: the function g whose integral on 0 to 1 every method estimates. Default Exponential.
Exponential rate a Exponential only: g(u) = e^(a·u), with a from 0.5 to 4 (default 1).
Hump tilt t Tilted hump only: g(u) = 4u(1 - u) + t·u, with t from 0 to 2 (default 0); 0 is the symmetric hump.
Kink position K Hockey stick only: g(u) = max(u - K, 0), with K from 0 to 0.9 (default 0.5); 0 is the straight line g(u) = u.
Event share P Event share only: g(u) is 1 when u is below P percent and 0 otherwise, with P a whole percentage from 1% to 99% (default 30%).
Seed The starting number of the random stream, a whole number from 1 to 2,147,483,646 (default 2026). The same seed always gives the same 40 repeats, and every method uses the same draws.
Evaluations N The evaluations of g each estimate may spend, a multiple of 8 from 8 to 64 (default 16). Antithetic pairs use N/2 draws and their N/2 mirrors.
Your control coefficient β for the control variate with your coefficient, from -10 to 50 (default 1). 0 gives plain sampling.
Challenge 0 for free exploration (the default), or 1 to 5 to load a challenge.
Your prediction Not yet predicted (the default), Plain, Antithetic pairs or Control variate: your answer in challenges 1 and 5. Outside those two challenges it changes nothing.

Each shape setting (a, t, K and P) belongs to one function. It is checked and read only while its own function is the function used; for the other three functions it is hidden, any value is accepted, and the model reads its shipped default instead, so it can change no result.

Where each input is set:

  • Outside the input panel: the function, chosen with the tabs over the function plot, and your prediction, chosen with the challenge's own buttons in challenges 1 and 5.
  • In the input panel: the seed, the number of evaluations, the shape setting of the chosen function (only that one is shown), your control coefficient and the challenge number.
  • The page shows its controls in three levels, Explore, Experiment and Advanced. A level changes only what the page shows, never a calculation; every input is sent at every level.

Governing relationships

The generator. The model implements Park and Miller's minimal standard generator (MINSTD) with the multiplier 48271. With M = 2³¹ - 1 = 2,147,483,647 and starting from s₀ = the seed, each state is

sₖ = MOD(48271 · sₖ₋₁, M), and each draw is uₖ = sₖ / M,

which lies strictly between 0 and 1. The first draw is therefore 48271 · seed reduced modulo M, not the seed itself. Every product stays below 2⁴⁷, so the integer sequence is exact. The model computes 2,560 draws in every state: repeat r owns draws 64(r - 1) + 1 to 64r, whatever N is, so a larger N extends each repeat's sample and keeps its first draws. Every method reads the same draws (common random numbers).

From a draw sᵢ the model forms three points:

  • the draw u = sᵢ / M;
  • its mirror u′ = (M - sᵢ) / M = 1 - u, formed exactly from the integer;
  • the stratified point v = ((i - 1) + u) / N for i = 1 to N, one point in each stratum from (i - 1)/N to i/N.

For the event share every test is done in whole numbers, so it never depends on a rounding: u < P/100 is tested as 100·s < P·M, and the stratified point as 100·((i - 1)·M + s) < P·N·M.

Exact moments. For each function the model evaluates in closed form the exact value θ = E g(U), the variance σ² = Var g(U), the pair term Vₐ = σ² + Cov(g(U), g(1 - U)), the control covariance C = Cov(g(U), U), the best coefficient β* = 12·C (because Var U = 1/12) and the residual R = σ² - 12·C², the variance per evaluation left after the best control.

  • Exponential, rate a: θ = (e^a - 1)/a; σ² = (e^(2a) - 1)/(2a) - θ²; Vₐ = σ² + (e^a - θ²), since E[g(U)·g(1 - U)] = e^a; C = (e^a/a - (e^a - 1)/a²) - θ/2; β* = 12·C; R = σ² - β*·C.
  • Tilted hump, tilt t: the hump 4u(1 - u) is symmetric about 1/2, so θ = 2/3 + t/2, σ² = 4/45 + t²/12, Vₐ = 8/45, C = t/12, β* = t and R = 4/45.
  • Hockey stick, kink K: with w = 1 - K and x = min(K, w), θ = w²/2, σ² = w³(4 - 3w)/12, Vₐ = x³(2 - 3x)/6, C = w²(3 - 2w)/12, β* = w²(3 - 2w) and R = (w·K)³/3.
  • Event share, P percent: with p = P/100, x = min(P, 100 - P)/100 and q = x(1 - x) = p(1 - p): θ = p, σ² = q, Vₐ = x(1 - 2x), C = -q/2, β* = -6q and R = q(1 - 3q).

The two correlations that explain the gains are ρₐ = Vₐ/σ² - 1, the correlation of g(U) and g(1 - U), and ρᵤ = C / √(σ²/12), the correlation of g(U) and U, clipped to -1 to 1. Antithetic pairs help when ρₐ is negative; the best control removes the share ρᵤ² of the variance.

The exact zeros are built into these forms: the straight line (K = 0) gives Vₐ = 0 and R = 0, the fair coin (P = 50) gives Vₐ = 0, and the symmetric hump (t = 0) gives R = σ² exactly.

The five estimators in one repeat. With the N draws u₁ … u_N of the repeat, their mean ū, and ḡ = (g(u₁) + … + g(u_N)) / N:

  • Plain: ḡ.
  • Antithetic pairs: the mean of the N values g(u₁) … g(u_(N/2)) and g(1 - u₁) … g(1 - u_(N/2)).
  • Control variate: ḡ - β̂·(ū - 1/2), where β̂ is the least-squares slope of g(uᵢ) on uᵢ over the repeat's own N draws, Σ(g(uᵢ) - ḡ)(uᵢ - ū) / Σ(uᵢ - ū)². The control works because the mean of U, 1/2, is known exactly.
  • Control, your coefficient: ḡ - β·(ū - 1/2), with your β.
  • Stratified: the mean of g(v₁) … g(v_N).

Exact variances at N. Plain: σ²/N. Antithetic pairs: Vₐ/N. Control variate at the best coefficient: R/N. Your coefficient: (R + (β - β*)²/12) / N, a parabola in β whose lowest point is at β* and which equals the plain variance at β = 0. The control variate lane uses the estimated coefficient β̂, so its exact spread shown beside it is the best-coefficient value R/N, the limit it approaches as N grows. Each exact standard deviation is the square root of the exact variance.

Exact stratified variance. With one draw in each of N equal strata the variance is the sum of the within-stratum variances divided by N². In closed form:

  • Exponential: with c = a/N, the within-stratum variance of e^(cX), X uniform on 0 to 1, is the series V_c = Σ dₙ·cⁿ over n = 2 to 20, with dₙ = (2ⁿ(n - 2) + 2)/(n + 2)!. With S = (e^(2a) - 1)/(e^(2a/N) - 1), the variance is V_c·S/N².
  • Tilted hump: ((t²/12 + 4/9) - 16/(45N²)) / N³.
  • Hockey stick: with y = K·N, J = INT(y) and r = 1 - (y - J), the variance is ((N - J - 1) + r³(4 - 3r)) / (12N⁴).
  • Event share: with f = MOD(P·N, 100)/100, the variance is f(1 - f)/N², exactly 0 when P·N is a multiple of 100.

Plain, antithetic and control variances fall as 1/N; the stratified variance falls about as 1/N³ for the smooth functions.

Within-repeat intervals. The 95% interval of a method in one repeat is its estimate plus or minus z times its standard error, a normal-approximation interval, with z the standard normal quantile at 0.975 (about 1.96):

  • plain: SE = √(Σ(g(uᵢ) - ḡ)² / ((N - 1)·N));
  • antithetic pairs: from the N/2 pair means, SE = √(Σ(pair mean - estimate)² / ((N/2 - 1)·N/2));
  • control variate: from the regression residuals eᵢ = (g(uᵢ) - ḡ) - β̂(uᵢ - ū), SE = √(Σeᵢ² / ((N - 2)·N)).

Your coefficient and stratified sampling get no interval: one draw per stratum leaves no within-repeat spread. An interval covers θ when the size of (estimate - θ) is at most the half-width plus 1×10⁻⁹ times the exact plain standard deviation, so a method with no spread is counted as covering.

Across the 40 repeats. For each method the model takes the mean of the 40 estimates and their empirical standard deviation (divisor 39). The exact variance ratio of a method is the plain variance over its variance, and the empirical ratio the same with the empirical variances; above 1 means tighter than plain sampling. A ratio is blank when the method's variance is at most 1×10⁻¹² times the plain variance (no spread). The exact variance times N is the variance per evaluation, the efficiency figure.

The narrowest method. Among plain, antithetic pairs and control variate (best coefficient), a method beats another when its exact variance is lower by more than 1×10⁻⁹ times the plain variance. The narrowest is the one that beats both others, otherwise Tie.

Lanes and bins. The lanes span θ plus or minus 4.2 exact plain standard deviations, cut into 21 bins each 0.4 plain standard deviations wide, with bin 11 centred on θ. An estimate falls in bin 11 + INT((estimate - θ)/width + 0.5); one beyond the lanes is drawn in the end bin and counted as outside.

The coefficient curve. At 41 coefficients βₖ = β* + h·(k - 20)/20, k = 0 to 40, with h = 1.25 · max(|β*|, |β - β*|, √(12R)), the curve gives the exact standard deviation √((R + (βₖ - β*)²/12)/N). Its range always holds 0, your β and β*, which is its middle point.

Calculation sequence

The model works through the relationships above in this order:

  1. It checks the entered values in the order of the status list under Errors and warnings.
  2. It fixes the values used: your inputs, or in a challenge the challenge's own values with the one input the challenge leaves to you.
  3. It generates the 2,560 draws of the seeded stream, 64 for each of the 40 repeats.
  4. It evaluates g at every draw, at the mirror of the first 32 draws of each repeat and at every stratified point.
  5. It computes the exact value, the exact moments and the exact variances of every method at N and at N = 8, 16, … , 64.
  6. For each repeat it computes the five estimates, the estimated coefficient, the three intervals, the cover flags and the lane bins.
  7. Across the 40 repeats it computes the means, empirical spreads, ratios, coverage counts, the narrowest method, the histogram counts and the coefficient curve.
  8. It sets the status and, in a challenge, scores the challenge.

Outputs and interpretation

  • Exact value of the integral: θ, to 6 decimals, the area under the function curve.
  • Exact standard deviations: of plain sampling, antithetic pairs, the control variate at the best coefficient, the control with your coefficient, and stratified sampling, at the N used.
  • Exact variance ratios: plain over antithetic, control (best coefficient), your coefficient and stratified. Above 1 the method is tighter than plain sampling at the same cost; blank means no spread at all.
  • Empirical standard deviations: the spread of each method's 40 estimates. With 40 repeats an empirical standard deviation carries roughly 11% error, so a five-fold narrowing is clear and a small one is not; read the exact figures beside them.
  • Empirical variance ratios: antithetic and control, from the 40 estimates.
  • Narrowest of plain, antithetic and control: Plain, Antithetic pairs, Control variate or Tie.
  • Best control coefficient β*, and the mean estimated coefficient, the average of the 40 values of β̂.
  • Correlations: of g(U) with g(1 - U) (negative values make mirror pairs help) and of g(U) with U.
  • Intervals: for plain, antithetic and control, how many of the 40 intervals cover θ (0 to 40) and their mean half-width. At 95% about 38 of 40 would cover on average; fewer is expected at small N and for a rare event.
  • Outside the drawn range: how many of the 200 estimates lie beyond the lanes; the critical value z; and the lane ends, the axis of the lanes.
  • Settings used: the function, its shape setting (blank for the other three), the seed, N and your coefficient actually used (a challenge's own while it is selected), with the formula of g and the model and module versions.
  • Tables: the 40 repeats with each method's estimate and lane bin; the first repeat's N points (the draw, its mirror for the first N/2 rows, and the stratified point, each with its g); the function at u = 0, 0.01, … , 1; the 21 bins with each method's count; the coefficient curve; the exact variances at N = 8 to 64; and a summary of the five methods side by side.

Reading the canvas: the function plot shades the area under g, which is θ, and marks the first repeat's points, each mirror point joined to its twin, and the strata. Each lane drops one dot per repeat at its estimate, with a line at θ and a bar one exact standard deviation either side; the narrower a lane's pile, the less spread the method has for the same cost. The coefficient chart shows the parabola with your coefficient and the best one marked. The variance chart plots the exact variances against N on log scales: plain, antithetic and control fall with slope -1, stratified much faster for the smooth functions. A method with zero exact variance has no point on a log scale.

What to take from the lab: every method here costs the same, yet their spreads differ by factors of tens or hundreds; mirror pairs help only when g(U) and g(1 - U) are negatively correlated and can double the variance on a symmetric function; a control variate removes the part of g that moves with u, and its coefficient matters less near the best value because the curve is flat there; and 40 repeats can rank methods only when the gap is large, which is why the exact ratio is always shown.

Challenges

Choosing a challenge number from 1 to 5 loads that challenge. It fixes the function, its shape setting, the seed, N and your coefficient, and leaves you only the input it names; a shape setting the challenge does not list takes its shipped default. The result reads MET (score 100) or NOT MET (score 0), with the goal, the value the challenge is scored on and a one-line feedback.

  1. Predict the tightest. For e^u at 32 evaluations, predict which estimator has the smallest spread: plain, antithetic pairs or control variate. Open: your prediction. Scored value: the narrowest method's code (1 Plain, 2 Antithetic pairs, 3 Control variate; blank for a tie). MET when your prediction names it.
  2. Same accuracy, fewer evaluations. For e^(4u), find the fewest evaluations at which antithetic pairs are at least as tight as plain sampling with 64. Open: N. Scored value: the antithetic standard deviation at N over the plain standard deviation at 64. MET when the antithetic variance at N is at most the plain variance at 64 (within 1×10⁻⁹ of it) and N - 8 does not already reach it (or N is 8).
  3. When the mirror fails. For the tilted hump, find the smallest tilt (to the nearest 0.05) at which antithetic pairs beat plain sampling. Open: the tilt. Scored value: the exact antithetic variance ratio at the tilt. MET when antithetic pairs beat plain sampling at the tilt (Vₐ below σ² by more than 1×10⁻⁹ of it) but not at the tilt 0.05 lower.
  4. Tune the control. For the event share of 20%, set your control coefficient so its variance is within 5% of the best possible. Open: your coefficient. Scored value: 100·((β - β*)²/12)/R, how far your variance lies above the best, as a percentage. MET at 5 or less.
  5. Spread target. For the hockey stick at 16 evaluations with this seed, choose a method whose 40 estimates all land within 0.05 of the exact value. Open: your choice of Plain, Antithetic pairs or Control variate (the estimated-coefficient lane). Scored value: the largest distance of that method's 40 estimates from θ. MET at 0.05 or less. This challenge is scored on one seed's estimates; another seed can change the answer for a borderline method.

Challenges 1 to 4 are scored on exact variances, so the seed does not decide them; challenge 5 is about the sampled estimates themselves.

Held back until you answer: in challenges 1 and 5, while your prediction reads Not yet predicted, the result is NOT MET with the prompt as feedback, the scored value is blank, and every estimate, spread, ratio, count and coverage result is withheld, together with the lanes, the bin counts, the coefficient curve and the variance chart. The exact value, the function curve and the first repeat's points, the best coefficient, the lane ends, the critical value and the settings used stay. Once you answer, every result appears and the challenge is scored. While challenge 4 is selected and not met, the best coefficient and the mean estimated coefficient are withheld (the coefficient curve stays). While challenge 2 is selected and not met, the variances against N are withheld.

Validation and status logic

The status reads the first match in the list under Errors and warnings. The NOT VALID checks apply to the entered values, inside a challenge too; a shape setting is checked only while its own function is the function used. The CHECK item applies to the computed estimates and is not raised while challenge 1 or 5 awaits your answer. A CHECK does not stop the calculation: every result is still shown.

Assumptions and limitations

  • Four fixed functions on 0 to 1 with one shape setting each, in one dimension; no typed formula. The integral is the only target.
  • Every estimate spends exactly N evaluations (N/2 pairs for antithetic sampling), N a multiple of 8 up to 64, and every method is repeated exactly 40 times.
  • The generator is deterministic and reproducible. It is a small linear congruential generator: its draws fall on a lattice and nearby seeds can give related streams. Seed 2,147,483,646 is the mirror of seed 1 (every draw is 1 - u), so the two give identical antithetic estimates. Common random numbers keep the comparison of methods fair. It is fine for teaching and wrong for serious simulation.
  • An empirical standard deviation from 40 repeats carries roughly 11% error; the exact values are the reference for ranking methods.
  • The estimated coefficient β̂ costs a little at small N: the control variate lane is slightly biased, its spread sits above the best-coefficient exact value shown beside it, and its interval covers less often than 95%. The lane with your fixed coefficient is unbiased and its exact spread is exact.
  • The intervals are normal approximations; coverage below 95% is expected at small N and for a rare event, where many estimates are 0 with a zero standard error.
  • Not modelled: other functions, more than one dimension, importance sampling, quasi-random points, more than one control, and intervals for your-coefficient and stratified estimates.
  • A value within the stated band of a threshold (the 1×10⁻⁹ tie band, the zero-variance guard, a cover or bin edge, a challenge limit) can go either way; the exact ties and zeros of the symmetric hump, the straight line, the fair coin and a stratified event share are built in exactly.

Restrictions and non-computing states

Every input is required. A shape setting that does not belong to the function used is not checked and does not take part.

Under NOT VALID every result and every table is blank, except the model and module versions, the challenge result (No challenge selected, or NOT MET when a challenge is selected), a score of 0, and the goal and not-met feedback of a selected challenge.

While challenge 1 or 5 awaits your answer, and while challenge 4 or challenge 2 is selected and not met, the results listed under Challenges are withheld, as described there.

Errors and warnings

The status messages, first match wins:

  • NOT VALID: choose an integrand from the list: the function is not one of the four.
  • NOT VALID: the exponential rate must be from 0.5 to 4, the tilt from 0 to 2, the kink from 0 to 0.9, and the event share a whole percent from 1 to 99: the shape setting of the function used is out of range, not a number, or (for the event share) not a whole percentage.
  • NOT VALID: the seed must be a whole number from 1 to 2147483646: the seed is blank, not whole or out of range.
  • NOT VALID: the number of evaluations must be a multiple of 8 from 8 to 64: N is out of range, not a number, or not a multiple of 8 (for example 12).
  • NOT VALID: your control coefficient must be from -10 to 50: the coefficient is blank or out of range.
  • NOT VALID: the challenge number must be a whole number from 0 to 5, and the prediction one of the listed choices: the challenge number or the prediction is not allowed.
  • CHECK: n of the 200 estimates fall outside the drawn range (the exact value plus or minus 4.2 plain standard deviations), so they are drawn at its ends and counted in the summary: n is the count of estimates beyond the lanes, for example with your coefficient far from the best one, or a rare event at small N.
  • OK: the run is computed with nothing to flag.

References

This laboratory is an educational model of variance reduction in Monte Carlo integration. It estimates the integral of a fixed function on 0 to 1 by plain sampling, by antithetic pairs that join each draw u with its mirror 1 - u, by a control variate that corrects the sample mean with the known mean of the draws (using a least-squares coefficient or one you choose), and by stratified sampling with one draw in each of N equal strata. The exact variance of every method comes from closed forms. Its random numbers come from the Park-Miller minimal standard (MINSTD) generator, a multiplicative linear congruential generator with modulus 2^31 - 1, here with the multiplier 48271, so every run is exact and repeatable from its seed. Each repeat gets a 95% normal-approximation interval for plain, antithetic and control estimates.

Sources and further reading

  • Antithetic sampling, stratification, common random numbers and control variates: A. B. Owen, Monte Carlo theory, methods and examples, 2013, chapter 8, Variance Reduction. Author's book page
  • The origin of antithetic variates: J. M. Hammersley and K. W. Morton, "A new Monte Carlo technique: antithetic variates", Mathematical Proceedings of the Cambridge Philosophical Society 52(3), 1956, pages 449-475. Cambridge University Press
  • Control variables (control variates) and the regression estimate of their coefficient: S. S. Lavenberg and P. D. Welch, "A perspective on the use of control variables to increase the efficiency of Monte Carlo simulations", Management Science 27(3), 1981, pages 322-335. doi:10.1287/mnsc.27.3.322
  • The minimal standard generator: S. K. Park and K. W. Miller, "Random number generators: good ones are hard to find", Communications of the ACM 31(10), 1988, pages 1192-1201. doi:10.1145/63039.63042
  • The confidence interval for a mean (the lab uses the normal critical value in place of Student's t): NIST/SEMATECH, e-Handbook of Statistical Methods, section 1.3.5.2, Confidence Limits for the Mean. NIST

No table or text from any of these publications is reproduced, and none of their authors or publishers has reviewed or endorses this laboratory.

This laboratory is for learning. Its results hold only within its stated ranges; 40 repeats can rank methods only when their spreads differ widely, and the generator is not meant for production simulation.

Links were current at build time. If one moves, search the document's title rather than reporting a broken link as a defect.

Results are informational and not professional advice. See our Terms of Use. Powered by SpreadsheetWeb · About · Privacy · Terms