Understand simulation errorLesson 16 of 76 · 7 min

An interval for a simulated mean

Construct an approximate confidence interval for a model expectation.

An interval for an expectation describes numerical uncertainty about a fixed model mean, not the range of individual outcomes. Coverage refers to repeated independent simulations: if each run constructs a 95% confidence interval, about 95% should contain that same fixed mean when the method's assumptions hold. One interval can miss it.

For independent finite-variance draws whose sample mean is approximately normal, use mean ± critical value × MCSE. A two-sided 95% interval leaves 5% outside: 2.5% in each tail. The normal 97.5th percentile, stats.norm.ppf(.975), is about 1.96; symmetry supplies the lower endpoint.

The normal approximation can work for the mean of many skewed outcomes, but is not automatic for tiny samples or poorly explored tails. The exponential model has a known expectation to check. Compare the short interval for that expectation with the central 95% of individual waits. More draws narrow numerical error, not the underlying wait distribution.

Yˉ\bar Y is the estimated mean, sYs_Y is outcome sample SD and n is the independent draw count; ± means form a lower and an upper endpoint.

Keep the interval target explicit
95% MC interval for meanCentral 95% of outcomes071421Wait (minutes)
95% MC interval for meanCentral 95% of outcomes071421Wait (minutes)
Yˉ±1.96 sY/n\bar Y\pm1.96\,s_Y/\sqrt n
Reference illustration. Published exponential reference. The short interval concerns the model expectation; the long percentile range concerns individual waits. More draws reduce numerical uncertainty about the mean, not the spread of waits.

Should a 95% interval for the expectation contain 95% of the individual waits?

Write a prediction (optional)

Seeded teaching simulation

Select Run Python below with the code unchanged.

Tools
About Python ↗

The code is editable. Press Ctrl+Enter or ⌘+Enter to run Python from the editor.

Published example output

This result comes from the original Python. Your runs appear above. Build environment ↗

Mean wait estimate (minutes): 5.0263
Approximate 95% MC interval: [4.9277 5.1249]
Known model expectation: 5
Outcome percentiles 2.5/97.5: [ 0.133 18.292]

Read the first result

Read Approximate 95% MC interval and check whether it contains Known model expectation. Outcome percentiles 2.5/97.5 answer a different question about individual outcomes.

Try an edit

Replace size=10000 with size=20 on the line that creates waits. Select Run Python. Then replace default_rng(2015) with default_rng(16) for a new sample. Select Run Python again. Compare the endpoints of Approximate 95% MC interval with Known model expectation after each edit. Why does a small skewed sample deserve more scrutiny?

Back to the Python editor

Scope. This normal interval is approximate and conditional on independent draws and adequate exploration of the outcome distribution.

Try a fresh case

A confidence interval for expected project duration is 9.9–10.1 days. What does it establish about individual projects?

Choose an answer
Need a hint?
Hint 1

Identify the interval’s target quantity.

Hint 2

Compare the mean with a randomly selected project duration.

Your notes