Quasi-Monte Carlo

Average a function over 1,024 points. Scatter them at random and the answer misses by about 0.038. Place them by Sobol's rule and it misses by 0.0029: 13 times closer, for the same cost.

Pick a point set and slide N. Watch where the points land and how far each average misses. Then we build, piece by piece, the measure of evenness, the digit trick, Halton and Sobol points, the error bound, the rate, and the error bars.

You need Monte Carlo averaging (the error falls like 1/√N) and a little Python. We build the rest from zero.

Part of the Monte Carlo family. Start with Monte Carlo if the 1/√N rule is new to you.

Fill the square

256

The function is f(x, y) = ex+y; its exact average is (e − 1)² = 2.9525. Halton and Sobol errors are exact for these points. The random bar is the typical (root mean square) miss, σ/√N with σ = 1.22; the dot is this draw. Error axis is logarithmic.

Chapter 0

Random Points Leave Holes

Drop 16 random points in 16 cells and count the cells they miss

You want the average of a function over the unit square: the mean brightness of one pixel, or the expected payoff of a trade. Monte Carlo drops N random points, evaluates the function at each, and averages. The error falls like 1/√N.

Where does that error come from? Look at where the points land. Random points do not know about each other, so some crowd together and some regions get none.

Count the empty cells

Each cell should get one point. Red cells got none. Switch the point set, then press New random draw a few times.

Each random draw uses a fixed seed, so it repeats. Halton uses bases 2 and 3 and starts at n = 1; Sobol is the unscrambled scipy sequence and starts at 0.

Work the number for 16 points in 16 cells. One random point misses a given cell with chance 15/16. All 16 points miss it with chance (15/16)16 = 0.356. So about 0.356 × 16 = 5.7 cells stay empty: a third of the square gets no sample at all.

Quasi-Monte Carlo (QMC) keeps the average and changes the points. It places them by a fixed rule so that every region gets its fair share. A point set built this way is a low-discrepancy set. Sobol's first 16 points fill all 16 cells. Halton's first 16 leave 2 empty, and at 64 points Halton leaves 10 of 64 empty, against 23 for random.

The failure, as symptom, measurement and fix

The symptom is an estimate that changes too much from run to run. To measure it, run 10 seeds and look at the spread, or count empty cells as above. The fix is not only more points. Better placed points remove the holes that cause the spread.

The road

  1. Discrepancy: one number for how uneven a point set is.
  2. The radical inverse: mirror the digits of n to fill a line.
  3. Halton: one prime base per axis (the hero's Halton button).
  4. Sobol: a fair share in every box (the hero's Sobol button).
  5. The error bound: error is at most wiggle times unevenness.
  6. The rate: nearly 1/N, until dimension bites (the hero's N slider).
  7. Effective dimension: why 360 dimensions can act like 3.
  8. Randomized QMC: error bars without losing the speed.
  9. The showcase: price an Asian option with 100 times fewer paths.
  10. The field guide: terms, numbers, code and the family map.
Sixteen random points fall in a 4 by 4 grid. About how many cells stay empty, and why?

Chapter 1

One Number for Evenness

Drag a box from the corner and find where the points betray their unevenness

Two people each hand you 64 points and say theirs are well spread. You need one number that decides. Here is a test. Take a box that starts at the corner (0, 0). If the points are even, the share of points inside the box equals the box's area.

Hunt the worst box

Drag on the square to move the box's far corner. The read-out compares the share of points inside with the area. Then press Find the worst box.

The page finds the worst box exactly. It tries corners at the points' own coordinates and at 1, with the edge counted in and out.

Name the parts. Call the box B. It runs from (0, 0) to a corner (t1, t2), so its area vol(B) is t1 × t2. Call the number of points inside it A(B), out of N points in all. The star discrepancy D*N is the worst gap between share and area, over every such box.

Say it aloud

D-star-N equals the max over boxes B of the size of: A of B over N, minus vol of B.

D*N
D-star-N the star discrepancy of N points: 0 is perfectly even, 1 is as bad as it gets.
maxB
the max over boxes B try every box that starts at the corner (0, 0) and keep the worst one. The worst case, not the average, decides.
| … |
the size of the absolute value: too many points and too few count the same.
A(B)
A of B how many of the points lie inside box B.
N
N the number of points in the set.
vol(B)
vol of B the box's area (its volume in more dimensions): t-1 times t-2.
In plain words

For each corner box B, count the points inside, divide by N, and subtract the area vol(B). Keep the largest gap. That gap is D*N.

With numbers

On a line a box is an interval [0, t]. Clumped set {0.10, 0.15, 0.20, 0.70}: at t = 0.20, A = 3, so 3/4 − 0.20 = 0.55. Even set {0.125, 0.375, 0.625, 0.875}: the worst gap is half a spacing, 0.125. The clumped set is 4.4 times less even.

In two dimensions, 64 Halton points score D* = 0.052. Two hundred random sets of 64 points average 0.148, nearly three times worse. A random set's discrepancy shrinks only like 1/√N. That is the 1/√N of Monte Carlo, seen from the points' side.

The failure, as symptom, measurement and fix

The symptom is a discrepancy that looks small but is wrong. A scan over a coarse grid of corners misses the worst box, and its cost grows like (grid size)d. To measure it, compare with the exact scan on a small set. The fix in practice is a closed-form cousin: scipy's qmc.discrepancy computes an L2 discrepancy (the centred one by default) with no scan.

What does the star discrepancy D*N measure?

Chapter 2

Mirror the Digits

Write n in base 2, read it backwards behind the point, and watch each new point split the largest gap

Equal spacing (1/N, 2/N, …) is perfectly even, but you must fix N first. To add one point you start over. You want a sequence: points you add one at a time that stay even after every step.

The trick: write the integer n in a base b, then read its digits backwards behind a point.

Mirror the digits

Press Next point. The digits of n flip behind the point, and the new point drops into the line. The blue band is the largest gap left.

Exact arithmetic, n from 1 to 64. The sequence in base 2 is the van der Corput sequence.

Name the parts. Write n in base b. Its digits are a0 (the last digit), a1, a2 and so on: n = a0 + a1b + a2b² + …. The radical inverse φb(n) puts those digits after the point in reverse order.

Say it aloud

phi-b of n equals the sum over k of a-k times b to the minus k plus one.

φb(n)
phi-b of n the radical inverse of the whole number n in base b: a number in [0, 1).
Σk
the sum over k one term for each digit of n, k = 0 for the last digit.
ak
a-k digit k of n in base b, from 0 to b − 1.
b−(k+1)
b to the minus k plus one the place value after the point: 1/b for k = 0, 1/b² for k = 1. The last digit of n becomes the first digit after the point.
In plain words

Write n in base b. Take the digits a-k from the last to the first. Put digit a-k at place b−(k+1) after the point and add them up.

With numbers

n = 6 in base 2 is 110, so a0 = 0, a1 = 1, a2 = 1. φ2(6) = 0/2 + 1/4 + 1/8 = 0.375. n = 5 is 101: φ2(5) = 1/2 + 0 + 1/8 = 0.625. Neighbours 5 and 6 land in opposite halves. In base 3, 7 is 21: φ3(7) = 1/3 + 2/9 = 0.556.

In base 2 the sequence runs 0.5, 0.25, 0.75, 0.125, 0.625, 0.375, 0.875. The last digit of n changes fastest, and it now decides the first half. So consecutive points jump to opposite sides, and each new point lands in one of the largest gaps. This is the van der Corput sequence. Its first 16 points have D* = 0.0625 = 1/N, within a factor of 2 of the best any 16 points can do, 1/(2N).

The failure, as symptom, measurement and fix

The symptom is a running average that drifts in one direction before it settles. Points taken in forward order (1/8, 2/8, 3/8, …) sweep left to right. The first half of the run sees only the left half of the line. To measure it, plot the running mean. The fix is the mirror: it makes every prefix of the sequence even.

To compute φ2(6), you write 6 in binary (110) and then…

Chapter 3

One Prime per Axis

Give each coordinate its own base, and watch large bases line the points up

The van der Corput sequence fills a line. A pixel or a trade needs two or more coordinates. What goes in the second one?

Base 2 again fails at once: point n becomes (φ2(n), φ2(n)), and every point sits on the diagonal x = y. You cover a line, not a square.

Pick two bases

Choose the bases, then slide N. Watch bases 17 and 19 at 16 points, then add points.

16

Points n = 1 to N. The correlation is the plain Pearson correlation of the x and y columns.

The Halton sequence gives each coordinate its own prime base. Call the dimension d and the d-th prime pd. Point number n is xn.

Say it aloud

x-n equals the list: phi-2 of n, phi-3 of n, and so on up to phi-p-d of n.

xn
x-n Halton point number n: d coordinates, each in [0, 1).
φ2(n)
phi-2 of n the first coordinate: n's digits in base 2, mirrored.
φ3(n)
phi-3 of n the second coordinate: the same n, mirrored in base 3.
φpd(n)
phi-p-d of n the last coordinate, in base p-d, the d-th prime: 5 for d = 3, 113 for d = 30.
In plain words

To make point n, mirror n in base 2 for the first coordinate, in base 3 for the second, and in the d-th prime p-d for the last. Different primes keep the coordinates from moving in step.

With numbers

n = 4. In base 2, 4 is 100, so φ2(4) = 0.001 in binary = 0.125. In base 3, 4 is 11, so φ3(4) = 1/3 + 1/9 = 0.444. Point 4 is (0.125, 0.444).

Large primes bring a known weakness. For n below 17, φ17(n) = n/17 and φ19(n) = n/19. Both grow in step, so the first 16 points lie on one straight line: correlation 1.00. With bases 2 and 3 the first 16 points have correlation −0.19. A 30-dimensional Halton set uses primes up to 113 and shows this Halton degradation in its last axes.

The failure, as symptom, measurement and fix

The symptom is stripes when you plot two high coordinates of a Halton set against each other. To measure it, compute the correlation of coordinate pairs over the first few hundred points. The fix is scrambled Halton, which permutes each base's digits at random, or a switch to Sobol, next chapter.

Why does Halton give each coordinate a different prime base?

Chapter 4

A Fair Share in Every Box

Cut the square into boxes of equal area in every allowed shape and check that Sobol puts one point in each

Halton hopes that different primes keep coordinates apart. Sobol works only in base 2 and guarantees a fair count in a whole family of boxes.

An elementary box in base 2 is a grid cell with sides that are powers of 1/2: 1/4 by 1/4, or 1 by 1/16. Take 2m points. If every elementary box of area 2t−m holds exactly 2t points, the set is a (t, m, d)-net. Smaller t is better; t = 0 means one point per box.

Check every box

Pick the number of points, then slide the box shape. Green boxes hold exactly one point; red boxes hold none or more than one.

4 × 4

Sobol is the unscrambled two-dimensional scipy sequence, starting at point 0. Its first 4, 16 and 64 points are (0, m, 2)-nets; we checked every shape.

Name the parts. The set has N = 2m points. Each elementary box has area vol = 2t−m. A fair share is N times the area.

Say it aloud

The count in each box equals N times vol, which is two to the m times two to the t minus m, which is two to the t.

count
count the number of points in one elementary box. A net makes this exact for every box.
N
N the number of points, a power of 2.
vol
vol the area of each box, 2 to the t minus m.
2m
two to the m N written as a power of 2: m = 4 for 16 points.
2t
two to the t the fair share. t is the quality parameter: t = 0 means one point per box.
In plain words

Take 2-to-the-m points. Cut the square into equal elementary boxes of area 2-to-the-(t minus m), in any allowed shape. Count the points in each box. A net puts exactly 2-to-the-t points in every one.

With numbers

Sobol's first 4 points: (0, 0), (0.5, 0.5), (0.75, 0.25), (0.25, 0.75). Here m = 2 and t = 0, so each box of area 1/4 holds 4 × 1/4 = 1 point. That holds for the 2 by 2 cells, the 4 tall strips and the 4 flat strips. Four random points do this for the 2 by 2 cells only with chance 4!/44 = 0.094.

How does Sobol build such points? Each coordinate has a list of direction numbers, bit patterns chosen from a polynomial in arithmetic on 0 and 1. Point n + 1 is point n with one direction number XOR-ed in. The first coordinate is the van der Corput set in a reordered sequence: 0, 0.5, 0.75, 0.25, 0.375, 0.875, 0.625, 0.125. Halton is not a base-2 net: its first 16 points leave 2 of the 4 by 4 boxes empty.

The failure, as symptom, measurement and fix

The symptom is a Sobol run with N = 1,000 that does a little worse than expected. The balance holds only at powers of 2. To measure it, count boxes as above. The fix is to ask for 2m points: random_base2(m) in scipy.

What makes Sobol hold up in many dimensions where Halton degrades?

Chapter 5

Error Is at Most Wiggle Times Unevenness

Make the function wiggle and the points uneven, and watch the real error stay under the bound

Even points should give a better average. The Koksma-Hlawka inequality says how much better, with no probability in it. It splits the error into two factors: one belongs to the function, one belongs to the points.

The function's factor is its total variation V(f): on a line, the sum of all its rises and falls from 0 to 1. A flat function has V = 0. A function that climbs from 0 to 1 once has V = 1. In more dimensions the matching quantity is the Hardy-Krause variation.

Push against the bound

The grey curve is f(x) = x + a sin(6πx). Raise the wiggle a to raise V(f). Switch the points and change N. The yellow bar is the bound; the other bar is the real error.

0.10
16

The exact average of f is 0.5 for every a. The page measures V(f) on a fine grid; D* is exact. Each random set uses a seed fixed by N.

Name the parts. The QMC estimate QN is the plain average of f over the N points. The true average is I, the integral of f over the cube. V(f) is the variation and D*N the star discrepancy from chapter 1.

Say it aloud

The size of Q-N minus I is at most V of f times D-star-N.

| … |
the size of the error, too high or too low.
QN
Q-N the estimate: (1/N) times the sum of f over the N points.
I
I the true average of f over the unit cube.
≤
is at most a guarantee for every point set, not an average over luck.
V(f)
V of f the variation: how much f rises and falls. It belongs to the function; you cannot change it.
D*N
D-star-N the star discrepancy of the points. It belongs to the points; this is the lever.
In plain words

Measure how much f wiggles, V(f). Measure how uneven the points are, D*N. Multiply them. The error of the average Q-N is never larger than that product.

With numbers

f(x) = x² on the points {0.125, 0.375, 0.625, 0.875}. Q4 = (1 + 9 + 25 + 49)/256 = 0.3281 and I = 1/3, so the error is 0.0052. f rises once from 0 to 1, so V(f) = 1. D* = 0.125. The bound is 1 × 0.125 = 0.125, 24 times the real error.

The split explains the whole field. Once you fix the function, V(f) is fixed. The only factor left is D*N, so QMC is the craft of making D*N small. The bound is loose: in the device, the real error sits well under the yellow bar.

The failure, as symptom, measurement and fix

The symptom is a bound of infinity. An indicator with a slanted edge, such as f = 1 when x + y > 1, has infinite Hardy-Krause variation, so the bound says nothing. QMC still helps such functions, but less. To measure the real gain, use the error bars of chapter 8. The fix is to smooth the integrand where you can.

For a fixed integrand, what does Koksma-Hlawka say about lowering the error?

Chapter 6

Faster Than Random, Until Dimension Bites

Race random points against Sobol on a log-log plot and raise the dimension

Monte Carlo pays a steep price for accuracy. Its error falls like 1/√N, so halving the error costs 4 times the points, and one more decimal digit costs 100 times.

For Halton and Sobol, D*N falls almost like 1/N. Name the parts: the dimension d, the number of points N, and a constant cd that depends on the construction and on d.

Say it aloud

D-star-N is at most c-d times log N to the d, over N.

D*N
D-star-N the star discrepancy of the first N points of a Halton or Sobol sequence.
≤
is at most a worst-case ceiling, like chapter 5.
cd
c-d a constant that depends on the dimension d and the construction, not on N.
(log N)d
log N to the d the natural log of N, raised to the power d. It grows slowly in N but fast in d.
N
over N the core of the rate: unevenness falls like 1/N, not 1/√N.
In plain words

Take the log of N, raise it to the power d, divide by N, and scale by c-d. Times V(f), by chapter 5, that ceilings the QMC error.

With numbers

With cd set to 1 for comparison: d = 1 and N = 64 give ln 64 / 64 = 4.16 / 64 = 0.065, below Monte Carlo's 1/√64 = 0.125. But d = 10 and N = 1,000,000 give 13.810 / 106 = 2.5 × 105, against 0.001. At d = 10 this ceiling drops below 1/√N only after about 1039 points.

The ceiling is a worst case. Real errors are much smaller, so measure them. The device averages a product of d bumps, each with average 1, with random points and with scrambled Sobol points, 24 runs at each N.

Race the two rates

On log-log axes, a rate N−p is a straight line of slope −p. Pick the dimension, then slide N to read the gap.

4,096

Computed offline with numpy and scipy.stats.qmc: f(x) = product over i of (π/2) sin(πxi), exact average 1. Each point is the root mean square error over 24 seeded runs; the fitted slopes wobble by about 0.1.

At d = 4 and N = 4,096, random points miss by 0.0157 and Sobol by 0.00036: 44 times smaller. At d = 16 the gap shrinks to 2 times, and at N = 16 Sobol is worse. Here every coordinate matters equally, the hardest case for QMC.

The failure, as symptom, measurement and fix

The symptom is QMC no better than Monte Carlo on a high-dimensional problem with a small budget. To measure it, compare error bars (chapter 8) at your real N. The fix is to move the important variation into the first few coordinates, next chapter.

To halve the error, roughly how many more points does each method need?

Chapter 7

Few Coordinates Matter

Build a random path two ways and see where its variance lives

In 1995 Paskov and Traub priced a mortgage-backed security with 360 monthly cash flows: an average over 360 dimensions. The ceiling of chapter 6 is useless there. Yet Sobol points beat Monte Carlo. Why?

Most of the integral's variation came from a few directions. A function can have nominal dimension 360 and still act like a function of 2 or 3 coordinates. The count that matters is its effective dimension.

Name the parts. Split the variance of f by coordinate, in the order the points feed them. Call Sk the share of the variance carried by the first k coordinates.

Say it aloud

d-eff is the smallest k for which S-k is at least 0.95.

deff
d-eff the effective dimension (in the truncation sense): how many leading coordinates do the work.
min
the smallest stop at the first k that passes.
k
k a count of leading coordinates: 1, 2, 3, and so on.
Sk
S-k the share of f's variance explained by coordinates 1 to k, from 0 to 1.
0.95
zero point nine five the cut-off: 95 percent of the variance.
In plain words

Add up the variance share of coordinate 1, then 1 and 2, then 1 to 3. Stop when the running total S-k reaches 95 percent. The count k is d-eff.

With numbers

Take g = ex1 + 0.05 × (sin x2 + … + sin x10). The first term has variance 0.2420. Each sine term has 0.0025 × 0.0614 = 0.00015, nine of them 0.0014. S1 = 0.2420 / 0.2434 = 0.994, so deff = 1 of 10.

Sobol balances its first coordinates best. So the trick is to feed the important directions into them. A random price path needs one normal draw per time step. The plain sequential build uses draw j for step j, which spreads the variance over all draws. The Brownian bridge uses draw 1 for the end point, draw 2 for the midpoint, draws 3 and 4 for the quarter points, and so on.

Where does the variance live?

Bars are each coordinate's share of the variance of the path's average. The grey line is the running total Sk; the yellow line marks 95 percent. Switch the build and the step count.

Exact, not sampled: the path average is linear in the normal draws, so each draw's share is its squared weight over the sum of squared weights. Both builds give the same path distribution.

With 16 steps the sequential build needs 11 coordinates to reach 95 percent. The bridge needs 3; its first coordinate alone carries 77 percent. Same paths, same distribution, a different order of draws.

The failure, as symptom, measurement and fix

The symptom is a QMC gain that vanishes when the draws feed time steps in order. To measure it, compute shares as above, or compare error bars with and without reordering. The fix is a Brownian bridge or a principal-component ordering of the draws.

Why can Sobol beat Monte Carlo on a 360-dimensional pricing problem?

Chapter 8

Randomize to Get Error Bars

Shift the whole point set at random, repeat, and read the error bar from the spread

Your manager asks for a confidence interval. Plain Sobol gives one fixed number. There is no spread to measure, so there is no error bar, and the Koksma-Hlawka ceiling is too loose to quote.

Randomized QMC (RQMC) moves the whole point set at random in a way that keeps it even. Each moved set gives an unbiased estimate. Repeat with independent moves and the spread of the estimates is your error bar.

The simplest move is the random shift (Cranley-Patterson rotation). Name the parts: a point xi and one random offset U, uniform on [0, 1)d. frac keeps only the part after the point.

Say it aloud

x-i-prime equals frac of x-i plus U.

x′i
x-i-prime point i after the shift.
frac
frac of the fractional part: 1.175 becomes 0.175. It wraps the cube around, so nothing leaves it.
xi
x-i point i of the fixed QMC set.
U
U one random offset per replicate, the same for every point, uniform on [0, 1) in each coordinate.
In plain words

Draw one offset U. Add it to every point x-i and wrap back into [0, 1). Average f over the shifted points x-i-prime. Repeat R times with new offsets; the R averages give a mean and a spread.

With numbers

Offset U = 0.8 on the points 0.375 and 0.625: frac(1.175) = 0.175 and frac(1.425) = 0.425. Both moved by the same amount, so their gap stays 0.25 and the set stays even.

The error bar is the standard error: the spread s of the R estimates divided by √R. With 20 shifts of 256 Sobol points on f = 2x × 2y (true average 1), s = 0.0083 and the standard error is 0.0083 / √20 = 0.0019. Twenty random sets of 256 give s = 0.061 and a standard error of 0.014, seven times wider.

Build the error bar

Each run draws a fresh random set (warm, top) and a fresh shift of the Sobol set (pink, bottom), both 256 points. Press Run and watch the two histograms grow.

20

Live in your browser: f(x, y) = 4xy on 256 points; the dashed line is the true value 1. Draws use fixed seeds, so Reset repeats them.

Owen scrambling permutes the digits of each coordinate at random instead. It is scipy's default (scramble=True). On the same test it gave s = 0.00045. Averaged over 500 scrambles, the estimate was 0.99998: no bias.

The failure, as symptom, measurement and fix

The symptom is an error bar that is far too small or far too big. It comes from treating the N points of one QMC set as independent and using s/√N. They are not independent. The fix is R independent randomizations, R of 10 to 30, and the spread across them.

What does randomized QMC give you over plain Sobol?

Chapter 9

Price an Asian Option

Race Monte Carlo, Sobol and Sobol with a bridge to the same accuracy on a 64-dimensional price

An Asian call option pays the amount by which a stock's average price over d dates beats a fixed price K, the strike. If it does not, it pays nothing. Each simulated price path needs d normal draws, so each path is one point in d dimensions. QMC turns a uniform point into normal draws with the inverse normal CDF.

Name the parts. Ā is one path's average price over the d dates. K is the strike. r is the interest rate and T the time to expiry in years. The price C is the discounted average payoff.

Say it aloud

C equals e to the minus r T, times the average over paths of the max of A-bar minus K and zero.

C
C the option's price today, in dollars.
e−rT
e to the minus r T the discount: a dollar paid in T years is worth less today. r = 0.05, T = 1 here.
avgpaths
the average over paths the Monte Carlo or QMC average over N simulated paths.
max( … , 0)
the max of … and zero the payoff: the gain if positive, else nothing.
Ā
A-bar one path's average stock price over the d dates.
K
K the strike price, $100 here.
In plain words

Simulate a price path and average its prices to get A-bar. Pay A-bar minus K if that is positive, else 0. Average the payoffs over all paths and discount by e to the minus r T.

With numbers

With made-up paths: one path has Ā = $108, so it pays $8; another has Ā = $95 and pays $0. Their average payoff is $4, and C = 4 × e−0.05 = $3.80. Over many paths, our toy model with 64 dates gives C = $5.84.

Race to one accuracy

Top: sample price paths and the strike. Bottom: error against paths. Teal is Monte Carlo, dashed pink is plain Sobol, solid pink adds the bridge. The yellow line is Monte Carlo's error at 16,384 paths. Pick the dates, then press Run.

Toy model, computed offline with numpy and scipy.stats.qmc: stock at $100, strike $100, volatility 0.2, r = 0.05, one year. Errors are root mean square over 20 seeded runs against a 218-path reference. The paths drawn on top are illustrative random paths.

With 64 dates and 16,384 paths, Monte Carlo misses by $0.062. Plain Sobol misses by $0.0089, seven times less. Sobol with the bridge misses by $0.0017. It matches Monte Carlo's 16,384-path accuracy with about 100 paths: some 160 times fewer.

The failure, as symptom, measurement and fix

The symptom is plain Sobol gaining less as the dates grow. To match Monte Carlo's 16,384-path error, it needs about 650 paths at 16 and 64 dates, against 125 at 4. To measure it, plot error against paths for each build. The fix is the bridge of chapter 7, which puts the path's overall level in coordinate 1.

In the 64-date race, what does the Brownian bridge change?

Chapter 10

The Field Guide

Keep the terms, the numbers, the checklist and the code in one place

QMC lowers the error of an average by choosing better points, not more points. It needs a known domain it can fill, usually the unit cube. Discrepancy measures the points, variation measures the function, and their product caps the error.

Terms and numbers

TermWhat it isNumber on this page
Star discrepancy D*Nworst gap between share of points and area, over corner boxes64 Halton points: 0.052; 64 random: 0.148 on average
Radical inverse φb(n)digits of n in base b, mirrored behind the pointφ2(6) = 0.375
Halton pointone prime base per coordinatepoint 4 = (0.125, 0.444)
(t, m, d)-netevery elementary box of area 2t−m holds 2t pointsSobol in 2-D: t = 0
Koksma-Hlawkaerror ≤ V(f) × D*Nx² on 4 points: error 0.0052, bound 0.125
RateD*N up to cd(log N)d/Nd = 4, N = 4,096: 44 times less error than random
Effective dimensionleading coordinates that carry 95% of the variance16-step path: 11 sequential, 3 with a bridge
Randomized QMCrandom shift or scramble, R replicates, standard error s/√R256 points: 0.0019 against 0.014 for random
Asian option, 64 datesC = e−rT × average of max(Ā − K, 0)about 100 bridge paths match 16,384 random ones

Before you trust a QMC number

The core, in code

import numpy as np
from scipy.stats import qmc

def rqmc_mean(f, d, m, R=20):
    """Average f over the unit cube with R scrambled Sobol sets of 2**m points."""
    ests = [f(qmc.Sobol(d, scramble=True, seed=r).random_base2(m)).mean()
            for r in range(R)]
    ests = np.array(ests)
    return ests.mean(), ests.std(ddof=1) / np.sqrt(R)   # estimate, standard error

f = lambda P: np.exp(P.sum(axis=1))               # exact average (e-1)**2 in 2-D
print(rqmc_mean(f, d=2, m=10))
# PyTorch has the same tool: torch.quasirandom.SobolEngine(dimension=d, scramble=True).draw(N)

Where it sits in the family

MethodIts leverError falls likeIt needs
Monte Carlorandom points1/√Nsamples from the distribution
Quasi-Monte Carlobetter pointsnear 1/N in low effective dimensiona domain it can fill, usually the cube
Importance samplingbetter weights1/√N, smaller constanta good proposal distribution
MCMCa chain that walks to the target1/√(effective sample size)the target up to a constant
Hamiltonian MCa chain moved by gradients1/√(effective sample size)the target's gradient
Sequential MCweighted particles, resampled over time1/√N per stepa model that moves step by step

QMC combines with the others. Importance sampling can draw its proposal through Sobol points. Path tracers in computer graphics sample pixels with Halton and Sobol points, and scipy (scipy.stats.qmc) and PyTorch (torch.quasirandom.SobolEngine) ship scrambled Sobol. Where you cannot sample the target at all, you need weights or a chain: importance sampling or MCMC. For search over a tree of choices, see Monte Carlo tree search.

The takeaway. Monte Carlo's error comes from holes and clumps. Fill the space on purpose, feed the important directions first, and randomize only to measure.
How does QMC lower the error, compared with importance sampling?

Now press Present or Teach and explain from memory: the empty cells, the mirrored digits, the fair share in every box, and the bound. Then go back to the hero, set N to 1,024, and say why Sobol's bar sits so far below the random one.

Quasi-Monte Carlo: better points, not more points
Monte Carlo · Back to Gleams