Learn more from fewer runsLesson 48 of 76 · 9 min
Spread points with randomised Sobol sampling
Compare randomised quasi-Monte Carlo estimates using independent scrambles.
Quasi-Monte Carlo points are designed to cover a domain more evenly than ordinary independent random points. A scrambled Sobol sequence introduces randomisation while retaining useful structure. It is a different sampling design, so the ordinary iid point-level error formula is not automatically appropriate.
Use a power-of-two point count with random_base2 to preserve the sequence’s balance properties. Each independent scramble produces one estimate. The spread across those estimates provides evidence about randomisation error for this experiment.
The example integrates a smooth two-dimensional function with known answer. Smoothness, dimension, variable ordering and discontinuities can all affect performance. Better coverage in one illustration does not imply every integrand or tail event will improve. Retain the method, scramble seeds and evaluation budget in the record.
- One scrambled set
- One integral estimate
- Independent scrambles
Should the structured points inside one scramble be treated as iid draws for the ordinary standard-error formula?
Write a prediction (optional)
Seeded teaching simulation
Select Run Python below with the code unchanged.
A saved draft is open. To run the published example, open Tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
Your result
Published example output
This result comes from the original Python. Your runs appear above. Build environment ↗
Exact integral: 2.952492 Scrambled Sobol mean / replicate SD: 2.952461 8.8e-05 Ordinary mean / replicate SD: 2.954853 0.046355 Points per estimate: 1024
Read the first result
The independent units for the displayed comparison are whole randomised estimates. Their count is twenty, not 20 times 1024 iid points.
Try an edit
Replace np.exp(points.sum(axis=1)).mean() with (points.min(axis=1) > .95).mean() and np.exp(rng.random((1024, 2)).sum(axis=1)).mean() with (rng.random((1024, 2)).min(axis=1) > .95).mean() and round((np.e-1)**2, 6) with round(.05**2, 6). Select Run Python again. Compare the second numbers in the two mean / replicate SD rows. They measure repeat spread when each trial counts points from the small region where both coordinates exceed 0.95.
Scope. Replicate spread estimates randomisation error, not model uncertainty. Few scrambles and rare discontinuous events can still give unstable evidence.
Try a fresh case
What is a defensible basic error check for this randomised QMC experiment?
Need a hint?
Hint 1
Locate where independent randomisation enters.
Hint 2
Keep the structured sample together as one replicate.