Monte Carlo, Part 3: Variance Reduction & Quasi-Monte Carlo#
The error of a Monte Carlo price is \(s/\sqrt{N}\). Doubling the accuracy by adding paths costs four times the work, but it can often be done by lowering \(s\), the spread of what is averaged, at almost no cost. This page sets out the main variance reduction methods, and quasi-Monte Carlo, which changes the rate of convergence itself. It is the third of four pages on Monte Carlo.
Variance reduction#
Each method keeps the estimate unbiased and shrinks its variance. The gain is measured as the variance ratio: the variance of plain Monte Carlo divided by the variance of the new method, for the same number of paths. A ratio of 100 is the same as 100 times as many paths.
Antithetic variates. For each normal draw \(Z\), also use \(-Z\). The two paths are negatively correlated, so the average of a pair has less variance than two independent paths, when the payoff is monotonic in \(Z\). It costs nothing, and the gain is modest.
Control variates. Find a quantity \(C\) that is correlated with the payoff \(Y\) and whose expected value is known exactly. Then
is unbiased for any \(b\), and its variance is lowest when \(b = \text{Cov}(Y, C) / \text{Var}(C)\). The variance is multiplied by \(1 - \rho^2\), where \(\rho\) is the correlation of \(Y\) and \(C\). A correlation of 0.99 cuts the variance 50-fold. The geometric Asian call is an excellent control for the arithmetic one, because the two averages are almost the same number.
Stratified sampling. Split the unit interval into equal strata and draw one uniform number in each, then convert them to normal draws. Every region of the distribution is represented in proportion, and the sampling variance of the terminal value falls sharply.
Importance sampling. For a deep out-of-the-money option almost every path pays nothing, and the price comes from the few that do. Draw the paths from a distribution that makes the payoff likely, and weight each by the ratio of the two densities. For a normal draw shifted by \(\theta\), the weight is \(e^{-\theta Z + \theta^2/2}\). The best shift puts the typical path at the strike.
Quasi-Monte Carlo#
Pseudo-random points leave gaps and clumps. A Sobol sequence is built to avoid them (Random Numbers & Sampling). For a smooth integrand of modest dimension the error falls close to \(1/N\). Three cautions apply:
The error is not a statistical one. The sequence is not random, so there is no standard error. Randomised quasi-Monte Carlo scrambles the points, and the spread across independent scrambles estimates the error.
The advantage falls with dimension. A path with 252 steps is a 252-dimensional integral. Sobol points are best in the first few dimensions, so the path is built with those dimensions assigned to the largest moves, for example by a Brownian bridge, and not in time order.
Kinks and jumps reduce the gain, because the integrand is not smooth.
Worked example#
The example prices the arithmetic Asian call with 12 fixings on 131,072 paths, then the benchmark European call by stratification, a deep out-of-the-money call at strike 160 by importance sampling, and compares Sobol with plain sampling for 4, 12 and 52 fixings.
Python code
"""Variance reduction and quasi-Monte Carlo: antithetic and control variates, stratification, importance sampling, Sobol."""
import numpy as np
from scipy.stats import norm, qmc
from common import K, R, S0, SIGMA, T, bs_price
from mc_paths_example import geometric_asian_call
N, FIX = 2**17, 12
DISC = np.exp(-R * T)
DT = T / FIX
def terminal_from_z(z):
return S0 * np.exp((R - 0.5 * SIGMA**2) * T + SIGMA * np.sqrt(T) * z)
def asian_pv(z):
"""Discounted payoffs of the arithmetic and geometric Asian calls from normals of shape (paths, fixings)."""
s = S0 * np.exp(np.cumsum((R - 0.5 * SIGMA**2) * DT + SIGMA * np.sqrt(DT) * z, axis=1))
arithmetic = DISC * np.maximum(s.mean(axis=1) - K, 0)
geometric = DISC * np.maximum(np.exp(np.log(s).mean(axis=1)) - K, 0)
return arithmetic, geometric
def line(name, est, se, base_se):
print(f"{name:<40} {est:9.5f} {se:9.5f} {(base_se / se) ** 2:14.1f}")
if __name__ == "__main__":
rng = np.random.default_rng(11)
g_exact = geometric_asian_call(FIX)
print(f"Arithmetic Asian call, {FIX} fixings, about {N:,} paths. Variance ratio is against plain Monte Carlo.\n")
print(f"{'Method':<40} {'Estimate':>9} {'Std error':>9} {'Variance ratio':>14}")
z = rng.standard_normal((N, FIX))
a, g = asian_pv(z)
base_se = a.std(ddof=1) / np.sqrt(N)
line("Plain", a.mean(), base_se, base_se)
half = rng.standard_normal((N // 2, FIX))
a_plus, _ = asian_pv(half)
a_minus, _ = asian_pv(-half)
pair = 0.5 * (a_plus + a_minus)
line("Antithetic", pair.mean(), pair.std(ddof=1) / np.sqrt(N // 2), base_se)
beta = np.cov(a, g)[0, 1] / g.var(ddof=1)
cv = a - beta * (g - g_exact)
line("Control variate (geometric Asian)", cv.mean(), cv.std(ddof=1) / np.sqrt(N), base_se)
print(f"{'':<40} correlation with the control {np.corrcoef(a, g)[0, 1]:.4f}, coefficient {beta:.4f}")
# Randomised Sobol points: 16 independent scrambles, with the spread of their means as the error.
means = []
for seed in range(16):
u = qmc.Sobol(d=FIX, scramble=True, seed=seed).random(N // 16)
means.append(asian_pv(norm.ppf(u))[0].mean())
line("Sobol (16 scrambles)", np.mean(means), np.std(means, ddof=1) / np.sqrt(16), base_se)
# European call: stratification of the terminal normal.
print(f"\nEuropean call, {N:,} paths. Black-Scholes {bs_price():.5f}")
print(f"{'Method':<40} {'Estimate':>9} {'Std error':>9} {'Variance ratio':>14}")
z1 = rng.standard_normal(N)
plain = DISC * np.maximum(terminal_from_z(z1) - K, 0)
base_se = plain.std(ddof=1) / np.sqrt(N)
line("Plain", plain.mean(), base_se, base_se)
strata = 1024
u = (np.arange(strata)[:, None] + rng.random((strata, N // strata))) / strata
pv = DISC * np.maximum(terminal_from_z(norm.ppf(u)) - K, 0)
line("Stratified (1024 strata)", pv.mean(), np.sqrt(pv.var(axis=1, ddof=1).mean() / strata / (N // strata)), base_se)
# Importance sampling for a deep out-of-the-money call: shift the mean so that the payoff is often positive.
strike = 160.0
exact_otm = bs_price(k=strike)
z1 = rng.standard_normal(N)
plain = DISC * np.maximum(terminal_from_z(z1) - strike, 0)
theta = (np.log(strike / S0) - (R - 0.5 * SIGMA**2) * T) / (SIGMA * np.sqrt(T))
shifted = z1 + theta
weighted = DISC * np.maximum(terminal_from_z(shifted) - strike, 0) * np.exp(-theta * shifted + 0.5 * theta**2)
print(f"\nCall with strike {strike:.0f}, Black-Scholes {exact_otm:.5f}. Shift of the normal mean: {theta:.3f}")
print(f"{'Method':<40} {'Estimate':>9} {'Std error':>9} {'Variance ratio':>14}")
base_se = plain.std(ddof=1) / np.sqrt(N)
line("Plain", plain.mean(), base_se, base_se)
line("Importance sampling", weighted.mean(), weighted.std(ddof=1) / np.sqrt(N), base_se)
print(f"Share of paths with a positive payoff: plain {np.mean(plain > 0):.1%}, shifted {np.mean(shifted * SIGMA * np.sqrt(T) > np.log(strike / S0) - (R - 0.5 * SIGMA**2) * T):.1%}")
# Dimension: Sobol helps less as the number of fixings rises, unless the path is built by a Brownian bridge.
print("\nSobol against plain, standard error of an arithmetic Asian call by number of fixings:")
print(f"{'Fixings':>8} {'Plain':>10} {'Sobol':>10}")
for fix in (4, 12, 52):
dt = T / fix
def pv_from(zz):
s = S0 * np.exp(np.cumsum((R - 0.5 * SIGMA**2) * dt + SIGMA * np.sqrt(dt) * zz, axis=1))
return DISC * np.maximum(s.mean(axis=1) - K, 0)
plain_pv = pv_from(rng.standard_normal((2**14, fix)))
sobol_means = [pv_from(norm.ppf(qmc.Sobol(d=fix, scramble=True, seed=s).random(2**10))).mean() for s in range(16)]
print(f"{fix:>8} {plain_pv.std(ddof=1) / np.sqrt(2**14):10.5f} {np.std(sobol_means, ddof=1) / 4:10.5f}")
The output is:
Arithmetic Asian call, 12 fixings, about 131,072 paths. Variance ratio is against plain Monte Carlo.
Method Estimate Std error Variance ratio
Plain 5.64931 0.02279 1.0
Antithetic 5.61588 0.01668 1.9
Control variate (geometric Asian) 5.63144 0.00062 1343.3
correlation with the control 0.9996, coefficient 1.0308
Sobol (16 scrambles) 5.63240 0.00104 477.0
European call, 131,072 paths. Black-Scholes 9.41340
Method Estimate Std error Variance ratio
Plain 9.39097 0.03885 1.0
Stratified (1024 strata) 9.41233 0.00081 2275.8
Call with strike 160, Black-Scholes 0.12130. Shift of the normal mean: 2.300
Method Estimate Std error Variance ratio
Plain 0.12860 0.00464 1.0
Importance sampling 0.12054 0.00040 137.8
Share of paths with a positive payoff: plain 1.1%, shifted 49.8%
Sobol against plain, standard error of an arithmetic Asian call by number of fixings:
Fixings Plain Sobol
4 0.07302 0.00247
12 0.06468 0.00827
52 0.06116 0.01205
Reading the output:
Antithetic variates help a little, with a variance ratio of 1.9. They are free, and worth using where the payoff is monotonic.
The control variate is far stronger. The arithmetic and the geometric Asian calls have a correlation of 0.9996, and the variance falls by a factor of 1,343, from a standard error of 0.0228 to 0.0006. The result, 5.6314, is consistent with the other estimates. The coefficient is 1.03, close to one, as it should be for two nearly equal quantities.
Stratification and importance sampling can be very strong in the right place. Stratifying the European call gives a ratio of 2,276. Importance sampling raises the share of paths that pay from 1.1% to 49.8% for the strike-160 call, and cuts the variance 138-fold. The shifted estimate, 0.12054, is within two standard errors of the true 0.12130.
Sobol beats plain sampling, and less so as the dimension rises. With 4 fixings the standard error is 30 times lower. With 52 it is only 5 times lower. The figure shows the same effect in one dimension: the Sobol error falls with a slope near -1 and the pseudo-random error with a slope of -1/2.
The plain estimate of the call, 9.391, is 0.6 standard errors from the truth, and the stratified estimate is within 0.0011 of it. The standard error of each method should be reported with its price.
A valuation control view#
A variance reduction method must keep the price unbiased: test it against a case with a known answer, as in the importance sampling example. A weight that is wrong, or a control variate with an estimated expectation, can bias the result while the standard error looks excellent.
Do not trust the small standard error alone: a standard error that falls by a factor of 100 after a change deserves a test of the price itself.
Record the settings of quasi-random runs: the dimension ordering, the scrambling and the number of points. A change in any of them changes the price, and the spread across scrambles is the only measure of the error.
Compare the independent price on the same footing: an independent Monte Carlo that uses plain sampling will have a larger standard error than the desk’s price that uses a control variate. The comparison should use the larger one.
Use the same control variate logic in reconciliations: the difference between the desk’s price and the independent price of the same trade, on the same random numbers, has far less noise than either price alone.
Next, Monte Carlo, Part 4: Greeks shows how the sensitivities are found by simulation.