VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

The Gold Standard of Scientific Computing | Monte Carlo Standard Error, Sample Size and Correlated Draws

A simulation estimates that an event occurs in 30 out of 100 independent runs. That gives a point estimate of 30%, but its Monte Carlo standard error is about 4.58 percentage points—not 0.3% or 1%. Increasing the number of independent trials from 100 to 400 halves this standard error. If successive draws are strongly correlated, even 400 iterations may carry far less information than 400 independent outcomes.

This guide separates the variability of individual simulated events from the uncertainty of an estimated average, derives square-root sample-size scaling, explains why apparent confidence can be misleading, and shows how effective sample size changes the interpretation of dependent Monte Carlo sequences.

Find the question you need

All chapters remain open. Choose a probability, simulation-size or correlated-draw route, or use the chapter index.

Distinguish outcomes and estimates

Chapters 1–3. Start this route.

Calculate Monte Carlo precision

Chapters 4–6. Start this route.

Understand correlation and ESS

Chapters 7–9. Start this route.

Audit models and practise

Chapters 10–12. Start this route.

Chapter index · Worked questions · Scientific Computing subject root

Chapter index

Distinguish outcomes and estimates · Chapters 1–3
Calculate Monte Carlo precision · Chapters 4–6
Understand correlation and ESS · Chapters 7–9
Audit models and practise · Chapters 10–12

CHAPTER 1 OF 12

1. Define the question a simulation is supposed to estimate

Back to contents

Suppose a model produces a binary outcome Y, with Y=1 when an event occurs and Y=0 otherwise. Its event probability is p=E[Y]. Run the simulator n times under a defined random mechanism and estimate p using p_hat=(Y₁+…+Yₙ)/n.

If the probability is unknown, p_hat is an estimate, not a newly discovered deterministic property that must be exactly equal to p. Its value changes between independently repeated batches of simulations. The purpose of Monte Carlo error analysis is to quantify that variation under the sampling mechanism.

For a teaching example, imagine the model’s true probability is p=0.30, known to us only so calculations can be checked. A sample of 100 independent trials might produce 30 successes. Then p_hat=0.30, perfectly matching p by coincidence; this does not mean the estimator has zero sampling uncertainty.

A real scientific simulation may estimate a mean, integral, risk or other statistic rather than a binary probability. The Bernoulli example is deliberately simple because its variance and Monte Carlo standard error can be derived exactly under independence.

Contents · Next · Subject root

CHAPTER 2 OF 12

2. Separate outcome standard deviation from standard error

Back to contents

A single Bernoulli outcome is zero or one. Its variance is Var(Y)=p(1−p). At p=0.30 this is 0.21, so the standard deviation of one outcome is √0.21≈0.4583, or 45.83 percentage points on a zero-to-one scale.

That is not the uncertainty of the estimated probability after many runs. For n independent identically distributed Bernoulli draws, averaging divides the variance by n: Var(p_hat)=p(1−p)/n. The corresponding Monte Carlo standard error is SE(p_hat)=√[p(1−p)/n].

At n=100 the standard error is √(0.21/100)≈0.04583, or about 4.58 percentage points. It is smaller than the variability of individual outcomes because the average combines many independent observations.

These two standard deviations answer different questions: how variable is one model outcome, and how variable is the sample-based estimate across repeated Monte Carlo experiments? A report that calls the raw event standard deviation its estimator precision confuses the two.

Contents · Previous · Next · Subject root

CHAPTER 3 OF 12

3. Calculate an actual hundred-run summary

Back to contents

Assume exactly 30 successes and 70 failures occurred among 100 independent simulations. Then p_hat=30/100=0.30. An estimated standard error using the plug-in probability is √[0.30×0.70/100]=0.04583.

Under the hypothetical known-true p=0.30 model, this coincides numerically with the theoretical standard error, but that equality depends on our constructed batch. Another batch with 25 successes would have p_hat=0.25 and a plug-in standard error √(0.25×0.75/100)≈0.04330.

The change in the plug-in standard error does not mean the simulation became more informative simply because fewer events happened; the underlying Bernoulli variance depends on the actual p, which is generally unknown. When probabilities are very close to zero or one, normal approximations and plug-in estimates need further care.

A careful results table records number of runs, number of events, estimated probability, standard-error method and any dependence or variance-reduction techniques used. Printing ‘30.000%’ alone hides the experiment’s limited precision.

Contents · Previous · Next · Subject root

CHAPTER 4 OF 12

4. Derive the square-root cost of reducing error

Back to contents

For fixed independent Bernoulli probability p, SE(p_hat) is proportional to 1/√n. Thus multiplying n by four cuts Monte Carlo standard error in half; multiplying n by a hundred cuts it by a factor of ten.

With p=0.30, n=100 gives SE≈0.04583, n=400 gives ≈0.02291, n=1000 gives ≈0.01449 and n=10000 gives ≈0.00458. These correspond to roughly 4.58, 2.29, 1.45 and 0.46 percentage points.

Why not claim four hundred runs are ‘four times more accurate’ than one hundred? Accuracy can refer to bias, mean squared error or other metrics. The standard error falls by two, while the variance falls by four. The metric must be named.

The cost can be significant: cutting the random error by a factor of five ordinarily requires around 25 times as many independent runs if no other method changes. Better algorithms and variance reduction may sometimes improve efficiency, but sample count alone follows this square-root law.

Independent draws nTheoretical SE at p=0.30Percentage points
1000.0458264.58
4000.0229132.29
10000.0144911.45
100000.0045830.46
Derived from √[p(1−p)/n]. These are theoretical independent-draw values, not observed simulation output.

Contents · Previous · Next · Subject root

CHAPTER 5 OF 12

5. Interpret a normal approximation without declaring certainty

Back to contents

For an event probability not too near zero or one and a sufficiently large independent sample, the central limit theorem motivates an approximate interval p_hat±1.96 SE_hat for a nominal 95% confidence procedure. For p_hat=0.30 and n=100 this gives approximately 0.30±0.0898, or about 21.0% to 39.0%.

This is an approximate statistical interval, not a guarantee that the true p is in a particular realized interval with 95% probability under a frequentist interpretation. The method is designed to cover the fixed unknown parameter in about 95% of repeated eligible experiments under its assumptions.

At small n or extreme p_hat, the simple symmetric normal interval can perform poorly and may even extend below zero or above one. Better-calibrated methods, such as Wilson intervals or exact binomial intervals, may be preferable for those cases.

Do not confuse this Monte Carlo sampling interval with physical model uncertainty. A model could estimate a probability very precisely yet represent the real world poorly because of incorrect inputs, structural assumptions or omitted processes.

Contents · Previous · Next · Subject root

CHAPTER 6 OF 12

6. Distinguish repeated batches from extending one batch

Back to contents

Suppose you run ten independent batches of 100 simulations. Each batch produces a probability estimate, and the empirical variation among those ten estimates offers a rough check of Monte Carlo uncertainty. The resulting batch estimates are not ten new model parameters; they are repeated measurements of the same underlying probability.

Pooling all independent outcomes into one batch of 1000 draws generally provides a more precise estimate than quoting one isolated batch of 100. Under p=0.30 the ideal standard error for 1000 draws is about 0.01449.

However, batch-level variation is itself noisy with only ten batches. If the code accidentally reuses the same random seed and regenerates identical output each time, the empirical batch variance may be zero even though the sampling uncertainty is not.

Random seeds are part of reproducibility, not a substitute for independence. Recording a seed helps reconstruct a run; choosing independent streams appropriately is necessary if the study relies on independence across replications.

Contents · Previous · Next · Subject root

CHAPTER 7 OF 12

7. Derive what correlation does to the variance of an average

Back to contents

For draws Y₁,…,Yₙ that may be dependent, Var(mean)=(1/n²)ΣᵢΣⱼCov(Yᵢ,Yⱼ). Under independence all cross-covariances vanish, leaving Var(Y)/n. When nearby draws are positively correlated, those extra covariance terms can enlarge estimator variance.

For an approximately stationary chain with common marginal variance σ² and autocorrelation ρ_k at lag k, a long-run approximation is Var(mean)≈(σ²/n)[1+2Σ from k≥1 ρ_k], provided the sum behaves appropriately.

The bracketed factor describes how serial dependence changes the information carried by n draws. It leads to an effective sample size n_eff≈n/[1+2Σρ_k]. Positive autocorrelation usually reduces effective sample size; some anticorrelated methods can increase it under suitable conditions.

This is why ‘one million iterations’ is not a complete uncertainty statement for a Markov chain Monte Carlo calculation or a correlated time-series simulation. The dependence structure and mixing behaviour are essential.

Contents · Previous · Next · Subject root

CHAPTER 8 OF 12

8. Calculate a correlated-draw counterexample

Back to contents

Construct an idealised stationary sequence whose lag-k autocorrelation follows ρ_k=0.8^k. The sum of positive lags is 0.8/(1−0.8)=4, so the long-run variance inflation factor is 1+2×4=9.

Therefore a long-run effective sample-size approximation is n_eff≈n/9. For n=100, this gives about 11.1 independent-equivalent draws, rather than 100. At p=0.30 the corresponding standard-error approximation is √(0.21/11.1)≈0.1375, much larger than 0.04583.

The n/9 calculation is asymptotic, because a finite record has an autocorrelation-weighted sum with factors depending on lag. It should be presented as an illustrative long-run approximation, not an exact finite-n confidence interval.

The point is conceptual but consequential: collecting many neighbouring states from a sticky simulation can yield less information than fewer independent draws. Longer runs, better transitions or suitable variance reduction may be needed.

Contents · Previous · Next · Subject root

CHAPTER 9 OF 12

9. Use effective sample size cautiously

Back to contents

Effective sample size is estimated from a finite correlated chain; it is not usually known as exactly as n. Empirical autocorrelations at large lags are noisy, and different estimators can truncate or regularise their sums differently.

For multiple Markov chains, separate concerns include warm-up, convergence diagnostics, mixing, multimodality and whether the chain reached the distribution being targeted. A large reported effective sample size cannot rescue a chain trapped in the wrong region of parameter space.

Stan’s reference manual describes effective sample size in terms of autocorrelation and Monte Carlo standard error. That framework is useful, but a reader should still ask which quantity’s ESS was calculated; different parameters or functions of one simulated state can have different correlations.

One global ESS for all results is often an oversimplification. Report uncertainty for the actual estimated statistic and explain how dependence was assessed.

Contents · Previous · Next · Subject root

CHAPTER 10 OF 12

10. Distinguish Monte Carlo error from modelling and numerical bias

Back to contents

Monte Carlo standard error concerns variation due to finite random sampling under a specified simulation procedure. It does not automatically account for programming mistakes, discretisation error, measurement bias, mis-specified model parameters or systematic approximation in the simulation algorithm.

For example, doubling a simulation run from 10,000 to 20,000 draws reduces ideal random error by about √2, but if the simulator uses the wrong physical rate constant, its estimate may converge very precisely to the wrong value.

Likewise, a pseudorandom generator with flawed implementation or an algorithm that never explores part of its intended distribution can invalidate the independent-draw formulas. More iterations do not correct a missing model state.

A trustworthy computational report separates sampling precision, numerical approximation and model validity. A small standard error is one component of evidence, not the whole meaning of accuracy.

Contents · Previous · Next · Subject root

CHAPTER 11 OF 12

11. Practise the number-of-runs and dependence calculations

Back to contents

Exercise A: A binary event has p=0.30 and n=400 independent simulations. Its theoretical standard error is √(0.21/400)≈0.02291, or 2.29 percentage points. It is half the standard error from n=100.

Exercise B: To reduce the ideal standard error from about 0.0458 to about 0.00458 without changing p or estimator, multiply the independent draw count by 100. One hundred runs become ten thousand.

Exercise C: A stationary chain has ρ_k=0.8^k. What is the long-run variance inflation factor? It is nine, yielding effective size about n/9. Explain why counting adjacent states as independent exaggerates precision.

Exercise D: A colleague reports 30% with zero uncertainty because three batches using the same seed all returned identical results. The batches are not evidence of independent replication. The seed and random-stream design must be examined.

Contents · Previous · Next · Subject root

CHAPTER 12 OF 12

12. Build a Monte Carlo reporting procedure that survives review

Back to contents

Identify the target statistic, sampling algorithm and assumptions about independent or dependent draws. Record n, number of batches, random generator and seed handling, and whether any observations were excluded or selected after seeing results.

For independent binary draws, report p_hat and a suitable standard error or confidence interval; for correlated chains, report estimated effective sample size and an appropriate Monte Carlo standard error with convergence checks. Avoid confusing the outcome standard deviation with uncertainty in the estimated mean.

Check results against a case with known analytic probability before applying the method to an unfamiliar system. Then vary simulation count and, where practical, compare independent repeated runs. A correct computational experiment should show error shrinking at a plausible rate rather than only producing more digits.

Continue from The Gold Standard of Scientific Computing to compensated summation and Euler stability. These distinguish randomness, floating-point effects and discretisation errors.

Contents · Previous · Subject root

Applied Monte Carlo methods lab

A probability estimate and its uncertainty are different deliverables

Imagine 30 success flags and 70 failure flags. Their average is 0.30, while the single-outcome standard deviation is about 0.458. Divide by √100 to obtain the standard error near 0.0458. The change is mathematical, not a choice of how many digits appear in a chart.

A results table should label point estimate, individual outcome spread and estimated standard error separately. The first describes the simulated event frequency; the second describes variation in one outcome; the third describes repeated-estimate uncertainty.

If the model parameters are themselves uncertain, a broader sensitivity analysis is needed. It is possible to estimate a model’s conditional event probability precisely while remaining uncertain about which model parameters are appropriate.

An experiment showing why four times as many runs halves SE

Compare ideal independent sample sizes n=100,400,1600 and 6400 with p=0.30. The respective theoretical standard errors are about 0.04583, 0.02291, 0.01146 and 0.00573.

Each fourfold increase halves the standard error. Equivalently, the variance decreases by a factor of four. This demonstrates why Monte Carlo precision tends to improve slowly as computational budgets grow.

Students can repeat the simulated batches and compare observed spread of estimates with the theoretical scale, while remembering that a small number of observed batches is itself a noisy measure of spread.

An autocorrelated-chain thought experiment

A sticky chain may retain a state for several steps before changing. Its outcomes are not independent just because each update uses fresh pseudorandom numbers. The next state depends on the previous one.

For an ideal stationary autocorrelation pattern 0.8^k, the approximate effective sample size is n/9. The calculation is conditional on that full lag pattern, not merely on seeing a lag-one correlation of 0.8.

An accurate report should examine the chain’s actual dependence and how it was estimated, because real autocorrelation need not follow this convenient geometric example.

A checklist for communicating scientific confidence

Write the model question, point estimate, uncertainty measure and interpretation in separate clauses. For example: ‘In 100 independent model replications, 30 events occurred; the estimated probability is 30% with an approximate plug-in Monte Carlo SE of 4.58 percentage points.’

Then disclose limitations: this uncertainty assumes the simulation mechanism is correctly implemented and independent across runs and does not represent real-world model uncertainty.

Readers can then distinguish a numerical estimate from a guarantee. Reproducibility comes from clear inputs and code; trustworthiness additionally requires appropriate assumptions and error accounting.

Frequently asked questions

Is the standard deviation of one simulation the same as its SE?

No. For independent draws the uncertainty of a sample mean is its individual standard deviation divided by √n.

Will four times the runs make the estimate four times more precise?

It halves standard error, assuming independent draws and the same estimator. Variance falls by four.

Do correlated iterations count as independent runs?

No. Positive serial correlation can greatly reduce effective sample size; error calculations should reflect dependence.

Sources and connected reading

The p=0.30 and autocorrelation examples are mathematical teaching models. Real applications require their own random-stream, model and dependence checks.

Return to reading routes

Advanced simulation lab: rare events, finite-chain errors and reproducibility

Derive the variance of a simulated proportion from first principles

Let Yᵢ be one Bernoulli trial, equal to one for success and zero for failure. E[Yᵢ]=p, while E[Yᵢ²]=p because 0²=0 and 1²=1. Therefore Var(Yᵢ)=E[Yᵢ²]−E[Yᵢ]²=p−p²=p(1−p).

For n independent copies, the sum X=ΣYᵢ has variance n p(1−p). The estimate p_hat=X/n divides that sum by n, so Var(p_hat)=[n p(1−p)]/n²=p(1−p)/n. The square root is the theoretical Monte Carlo standard error.

This derivation explains both the numerator and the square-root sample-size improvement. We are not selecting a mathematical formula merely because it is widely printed in statistics textbooks; we can show why it follows from independence and Bernoulli outcomes.

When samples are dependent, the step Var(ΣYᵢ)=ΣVar(Yᵢ) is no longer generally valid because covariance terms remain. That is exactly the assumption that must be revisited for sequential Markov chain draws.

Why zero observed successes does not prove zero uncertainty

Suppose one hundred independent simulations report no successes. Then p_hat=0, and the naive plug-in expression √[p_hat(1−p_hat)/n] equals zero. But this does not prove the true event probability is zero; rare events can fail to occur during a finite run.

For instance, if the true event probability were 0.01, the chance of observing no successes in 100 independent runs would be 0.99¹⁰⁰≈0.366. A zero-count batch would therefore be quite plausible under a genuinely nonzero probability.

The example exposes a boundary failure of the simple plug-in standard error. Near zero or one, use suitable binomial uncertainty methods and report the count, not a falsely exact ‘0.000% ± 0.000%’.

The issue also warns against overinterpreting Monte Carlo absence as a safety guarantee. One hundred uneventful simulation runs cannot establish that an adverse event has zero probability, especially if the model assumptions themselves are uncertain.

Calculate the finite-chain correction for geometric autocorrelation

Our main article used an asymptotic integrated-autocorrelation example with ρ_k=0.8^k and variance inflation approaching nine. At finite n, the stationary sample-mean variance has the exact lag-weighted factor 1+2Σ from k=1 to n−1 (1−k/n)ρ_k, under the stated common-variance stationary model.

For n=100 with ρ_k=0.8^k, the sum is close to 3.8 rather than four because distant pairs occur less often. The finite-n variance inflation factor is therefore about 8.6, giving effective independent-equivalent sample size roughly 100/8.6≈11.6.

The approximation n/9≈11.1 is still a useful long-run indicator but should not be described as the exact answer for a finite record. This distinction makes the formula more informative: positive serial correlation reduces precision, while finite sample length determines how strongly each lag enters.

Estimating these correlations from a real chain is itself uncertain. Diagnostics should use appropriate estimators and several chains where relevant rather than assuming the convenient geometric pattern applies to every simulation.

A reproducibility exercise with random-number streams

Imagine a script creates five batches of 100 model runs by setting the same pseudorandom seed before every batch. The batches can then be identical. Seeing identical p_hat values is not evidence of low Monte Carlo uncertainty, because the five outputs are not five independent replications.

Change the workflow so independent random streams are used appropriately, or generate one long independent stream and partition it into genuinely disjoint batches under a suitable generator. Record the seeding protocol and sample allocation.

Parallel simulations require care when work is split across machines. Merely using different processor numbers does not prove random streams cannot overlap, and reproducibility requires identifying the generator, relevant version and stream management.

An educational report can give one seed for a demonstration while distinguishing it from evidence obtained across repeated independent runs. Reproducibility and statistical independence are complementary requirements, not synonyms.

Distinguish ordinary sampling from variance-reduction methods

Some Monte Carlo algorithms deliberately use stratification, antithetic pairing, importance weights or other techniques to reduce estimator variance. Their output records may not be independent unweighted Bernoulli draws, even if the target quantity remains an event probability.

In such cases the textbook √[p(1−p)/n] formula cannot automatically be applied to the raw record count. The uncertainty analysis must reflect the actual estimator and sampling design, including covariance or weight dispersion.

Variance reduction can be valuable because ordinary independent Monte Carlo errors shrink only as 1/√n. But a method advertised as more efficient still needs validation, bias checks and a clear cost comparison against an independent reference.

The reporting principle remains constant: define the target statistic, define the estimator, state its assumptions, and then calculate uncertainty appropriate to that estimator rather than borrowing an unrelated formula.

Plan the simulation budget from a precision target

Suppose a study wants a theoretical Monte Carlo standard error no greater than one percentage point for an independent Bernoulli probability near p=0.30. From √[p(1−p)/n]≤0.01, rearrange to n≥0.21/0.0001=2100 independent draws. This is a sampling-precision calculation, not a guarantee about model correctness.

With the same estimated probability, 2100 independent draws give an approximate 95% normal interval half-width of 1.96×0.01=0.0196, or 1.96 percentage points. If draws are positively correlated, the required total iteration count could be much higher because the effective sample size is smaller. Record the actual estimator and assumptions before promising a numerical error margin.