Understand simulation errorLesson 15 of 76 · 7 min

Calculate Monte Carlo standard error

Estimate numerical uncertainty for a mean from independent simulation draws.

The Monte Carlo standard error, or MCSE, estimates the repeated-simulation standard deviation of an estimator. For a mean of independent identically distributed finite-variance outcomes, use their sample standard deviation divided by the square root of the number of trials.

The sample standard deviation uses ddof=1 to account for estimating the mean. MCSE has the same units as the estimated mean. It is different from a relative error, which divides by an appropriate scale and becomes unstable near zero.

Repeated simulation batches provide an independent check of the formula in a tractable model. Compare the predicted standard error with the observed spread of batch means. This check relies on independent batches; replaying the same seed would make the apparent between-batch spread disappear.

YiY_i is outcome i; Yˉ\bar Y is their sample mean. ∑i\sum_i means add all the indexed outcomes. sYs_Y is sample SD and n is the number of independent trials.

Numerical error belongs to an estimator
  1. Independent outcomes
    Y1,…,YnY_1,\ldots,Y_n
  2. Estimate a model mean
    Yˉ=1n∑iYi\bar Y=\frac1n\sum_iY_i
  3. Estimate numerical spread
    MCSE^=sY/n\widehat{\mathrm{MCSE}}=s_Y/\sqrt n
Reference illustration. The estimated MCSE has the same units as the estimated mean. It concerns independent Monte Carlo draws, not real-world variation or uncertainty about model assumptions.

Should the MCSE have squared units or the same units as the outcome?

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 ↗

Estimated mean wait (minutes): 5.0204
Estimated MCSE (minutes): 0.1103
Model SE (minutes): 0.1118
SD of independent batch means: 0.1179

Read the first result

The estimated MCSE fluctuates because it uses a finite sample SD. It should be in the same broad range as the independent-batch and model calculations.

Try an edit

Replace n = 2000 with n = 8000. Select Run Python again. Compare Estimated MCSE (minutes), Model SE (minutes) and SD of independent batch means across runs. How close is the observed change to the square-root prediction of half the error?

Back to the Python editor

Scope. A finite estimated MCSE can be misleading for poorly explored tails or infinite-variance outcomes.

Try a fresh case

Your draws come from a slowly moving sequence of dependent draws. Can you automatically use s/ns/\sqrt{n} with the raw draw count?

Choose an answer
Need a hint?
Hint 1

State the formula’s sampling assumption.

Hint 2

Ask whether a new draw depends on the previous one.

Your notes