Four Times the Paths, Half the Error
The standard error of a Monte Carlo estimate falls like one over the square root of the number of paths: four times the paths halve it, and a hundred times the paths give one more digit. The actual miss is random and only typically of that size.
The question
More paths give a steadier estimate, but how much steadier? Is doubling the paths enough to halve the error, or does it take more? The last lesson showed that the standard error is the sample standard deviation divided by the square root of n. The sample standard deviation settles near a fixed number as n grows, so the standard error is about a constant divided by the square root of the number of paths.
That law says what an extra digit costs, and this lesson shows it in a run and then turns it into a number of paths. The prices come from a made-up model, and the cost is a count of paths in this model, not a statement about any real computation.
Work it by hand
If the standard error is c divided by the square root of n, then four times the paths give c divided by the square root of 4n, which is half of it. A hundred times the paths give a tenth of it: one more decimal digit costs a hundred times the work.
The run below starts with 100 paths and doubles eight times, which gives nine path counts. Each step of two doublings quadruples the paths, so the standard error should halve from the first to the third, the third to the fifth, and so on: from 100 paths to 400 to 1,600 to 6,400 to 25,600. The prediction is not exact, because each standard error is itself estimated from its own samples. The run shows how close it comes.
Run it
The program prices the call in the closed form (line 3), then prices it nine times with pricing.monte_carlo_plain, doubling the number of paths from first each time (lines 8 to 14). For each count it keeps the standard error from run.stderr() (line 11) and the distance between the estimate and the closed form (line 12), both in cents with one decimal. Lines 15 to 17 return the lists and line 18 returns the closed form in whole cents.

let m = model.black_scholes(spot, rate, 0.0, vol);
let call = instrument.european_call(strike, 1.0);
let exact = pricing.price(call, m, pricing.analytic()).price();
let label = str_list();
let se = float_list();
let miss = float_list();
let paths = first;
for (k in range(0, 9)) {
let run = pricing.price(call, m, pricing.monte_carlo_plain(paths, seed));
label.add(str(paths));
se.add(lmf.round(run.stderr() * 100.0, 1));
miss.add(lmf.round(abs(run.price() - exact) * 100.0, 1));
paths = paths * 2;
}
lmcode_return_put("label", label);
lmcode_return_put("se", se);
lmcode_return_put("miss", miss);
let answer = int(math_round(lmf.round(exact, 2) * 100.0));
{
"answer": 1045,
"label": [
"100",
"200",
"400",
"800",
"1600",
"3200",
"6400",
"12800",
"25600"
],
"se": [
143.5,
99.7,
72.8,
51,
36.8,
25.9,
18.3,
12.9,
9.1
],
"miss": [
162.6,
73.4,
31.6,
20.8,
0.1,
7,
3.7,
12,
15
]
}With seed 42 and 100 paths to start, the standard error in cents is 143.5, 99.7, 72.8, 51.0, 36.8, 25.9, 18.3, 12.9 and 9.1, and the distance to the closed form is 162.6, 73.4, 31.6, 20.8, 0.1, 7.0, 3.7, 12.0 and 15.0. From 100 to 400 paths the standard error falls by about a half, and so it does from 400 to 1,600 and from 1,600 to 6,400. Another seed gives other numbers.
You can change first and seed, and the inputs of the option. Keep first at most 390, so that the largest count stays below 100,000 paths and the page stays quick; a larger one takes longer.
A first of 1 stops line 9 with "monte carlo: the standard error needs at least 2 paths, got 1", one of 0 or less with "monte carlo: paths must be 1..4000000" and the value you gave (got 0 for 0), and one above 15625 with "monte carlo: paths must be 1..4000000, got 4000256" (the message for 15626).
A seed of 0 stops line 9 with "pricing.monte_carlo_plain: seed must be 1..2147483647 (0 would mean a clock-based seed), got 0". A spot or a volatility of 0 or less stops line 1 with "model.black_scholes: spot must be positive" or "model.black_scholes: volatility must be positive", and a strike of 0 or less stops line 2 with "option strike must be positive". Inputs far outside any sensible range stop the run as well: a rate of 800 stops line 3 with "discount (0) must be positive".
Your turn
A run of paths paths had the standard error stderr, and the standard error falls like one over the square root of the number of paths. The program below is meant to return the smallest number of paths for which the standard error is at most target, as a whole number. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on five others.

let ratio = target / stderr;
let needed = float(paths) * ratio * ratio;
let whole = floor(needed);
let answer = int(whole);
if (needed > whole) { answer = answer + 1; }
{
"answer": 128
}A run of paths paths had the standard error stderr, which falls like 1 / sqrt(n) in the number of paths n. Return the smallest whole number of paths for which the standard error is at most target. Check runs each candidate on the data shown and on five others.
Read the result carefully
The law is about the typical size of the error. The actual error of a run is random: in the demo, at 25,600 paths the estimate is 15.0 cents from the closed form while the standard error is 9.1 cents, about 1.65 standard errors. A larger count does not guarantee a smaller miss.
The law also does not make the model truer. The model's constant volatility and its lack of costs are assumptions that more paths leave untouched. The exercise only turns the law into arithmetic on the given numbers.
The demo shows its standard errors and misses in cents with one decimal because the engine works in binary floating point and a raw result can end in a stray digit; the exercise returns a whole number of paths, rounded up. It is a description of an arithmetic model and not investment advice.
Recap
- The standard error falls like 1 / sqrt(n): four times the paths halve it, a hundred times the paths divide it by ten.
- The needed number of paths for a target standard error is the current paths times (stderr / target) squared, rounded up.
- The actual miss is random: it is only typically about one standard error.
- More paths shrink the sampling error, not the error of the model's assumptions.