Learn more from fewer runsLesson 45 of 76 · 8 min
Give every part of the domain a turn
Construct a stratified estimator with correct stratum weights.
Stratification divides a sampling domain into known pieces, samples within each piece and combines their estimates with the correct weights. For equal-width intervals under a uniform distribution, each stratum has equal probability weight.
Compare ordinary uniform sampling with one random point from each of n equal intervals. Every replicate has the same evaluation budget. Independent replicates let you estimate the spread of the resulting estimators without pretending the stratified points are ordinary iid uniform draws.
The improvement depends on the integrand and stratification. If strata have unequal probability or receive unequal sample counts, the combination must retain their weights. A raw average of all sampled values can otherwise target the wrong distribution.
is stratum h, one piece of the domain. joins all pieces; is the piece's probability weight and is its sample function mean.
- Partition the domain
- Sample inside each part
- Weight the stratum means
Will one draw in every equal-width interval leave the same gaps as ordinary random draws?
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 expectation: 0.3333333333333333 SD across ordinary estimates: 0.029888 SD across stratified estimates: 0.000338 Evaluations per estimate: 100
Read the first result
The comparison uses equal evaluations per estimate. Replicate-level spread is the relevant numerical-error evidence here.
Try an edit
Replace rng.random((repetitions, n))**2 with rng.random((repetitions, n)) > .973 and stratified_u**2 with stratified_u > .973 and print("Exact expectation:", 1/3) with print("Exact expectation:", 1-.973). Select Run Python again. Read Evaluations per estimate and compare SD across ordinary estimates and SD across stratified estimates for the new indicator.
Scope. The example is one-dimensional with equal strata. High-dimensional or poorly chosen strata need separate analysis.
Try a fresh case
Two strata have probabilities 0.9 and 0.1, but you sample equally many draws in each. How should their mean estimates be combined?
Need a hint?
Hint 1
Identify the population weight of each stratum.
Hint 2
Do not confuse deliberate allocation with target probability.