A simulation of 10,000 trials reports that an event occurred in 2484 of them, an estimate of . How far from the true probability might that be, and would four times as many trials make it four times as accurate? The estimate is an average of zeros and ones, so the results about sample means answer both questions. This lesson derives the standard error of a simulation estimate, reads two actual seeded runs against a known answer, shows how to estimate or bound the standard error when the probability is unknown, and separates the random error of a finite run from mistakes in the model or the program.
Key terms
Simulation estimate
Definition Let be an event in a probability model with . A simulation runs trials of the model and records the indicator , equal to if occurs in trial and otherwise. With , the number of trials in which occurred, the simulation estimate of is
Each indicator is , so linearity gives for every , whether or not the indicators are independent. If they are independent, then and
In plain words A simulation estimate is a sample mean of zeros and ones. It is unbiased, so it is right on average over possible runs, but one run gives one value, which generally differs from .
Example As a benchmark with a known answer, take an event with . One indicator has mean and variance . For this lesson the benchmark was actually simulated in Python 3.12 with the generator random.Random(20261012), counting a trial as a success when the uniform draw from random() is below . The recorded run had 30 successes in the first 100 trials, 249 in the first 1000 and 2484 in all 10,000, so the estimates were , and .
Monte Carlo error
Definition The Monte Carlo error of a simulation estimate is the difference that comes from using finitely many simulated trials. For independent indicators its standard deviation, called the standard error of , is
Multiplying by halves the standard error, and dividing the standard error by takes times as many trials. A standard error is not a largest possible error. A rigorous bound on the probability of a large error comes from Chebyshev’s inequality, which gives, for every ,
In plain words The standard error measures the typical size of the Monte Carlo error across possible runs with the same number of trials. Precision grows with the square root of the number of trials, so cutting the standard error by a factor of costs a hundred times as many trials. A particular run can land closer to than one standard error or farther away.
Example For and ,
about percentage points. With 40,000 trials it would be . Chebyshev’s inequality with bounds the probability of an error of at least by
In the recorded run the errors were after 100 trials, after 1000 and after 10,000. So the run was farther from after 10,000 trials than after 1000. That does not contradict the shrinking standard error, which describes the spread over possible runs of each length and does not promise that one run moves closer to at every step.
Plug-in standard error
Definition When is unknown, the plug-in standard error replaces by the estimate,
It is computed from the run, so it is itself random, and it is an estimate of the standard error, not the standard error itself. It equals whenever or , whatever the true .
In plain words Plugging in the estimate is a practical way to report the size of the Monte Carlo error when the true probability is the very thing being estimated. It is a sensible approximation when the run contains many successes and many failures, and it can mislead for rare events, where a short run may contain no successes at all.
Example For the recorded run, gives , close to the true . Now take a rare event with and a run of 1000 independent trials. The chance of zero successes is , and such a run reports the estimate with plug-in standard error . Neither number shows that the event is impossible or that the estimate is exact, since many positive probabilities make zero successes quite likely.
Conservative standard error
Definition For every in the identity shows that , with equality exactly at . So for independent indicators
and the conservative standard error bounds the true standard error without any knowledge of .
In plain words The worst case for the variance of an indicator is a fair coin. Planning with the worst case guarantees that the actual standard error is no larger, which makes it useful for choosing the number of trials before a run. For probabilities near or the bound can be far above the real standard error.
Example With the conservative standard error is , a little above the true for . A standard error of at most for every needs , which holds exactly when . For the rare event with and , the true standard error is about while the conservative value is about , valid but very loose.
Replication
Definition A replication is a complete new run of the whole simulation experiment, with the same model, event and number of trials, whose random inputs are modeled as independent of those of the other runs. The estimates from several replications show the run-to-run variation directly. Continuing one run adds trials to the same estimate. Running the same program again with the same generator and seed reproduces the same sequence, so such a rerun is a reproducibility check, not a replication.
In plain words A fresh replication gives new information about how much the estimate varies. An exact rerun should return identical output, which confirms the computation but says nothing new about Monte Carlo error. Picking whichever seed gives the most pleasing result after seeing the output hides exactly the variability that replications are meant to show.
Example A second run of the same algorithm with seed 20261013 gave 2510 successes in 10,000 trials, an estimate of . The two estimates and lie below and above , both within one standard error. Running the first program again with seed 20261012 gives 2484 successes once more, which checks reproducibility and adds no new estimate. Treating the streams from different seeds as independent is a working assumption about the generator.
Model error and implementation error
Definition Model error is the difference between the probability of the event in the simulated model and its probability in the real process that the model is meant to describe. Implementation error is a mismatch between the program and the stated model or event, such as counting the wrong event, using a wrong parameter or boundary, or making trials dependent where the model treats them as independent. If a program produces independent and identically distributed trials, its estimate converges in probability to the success probability of the trials it actually produces, so neither kind of error shrinks as grows.
In plain words More trials shrink the typical Monte Carlo error and leave the other two untouched. A precise estimate of the wrong quantity is still wrong. Comparing a program with an exact benchmark catches many implementation errors, while checking the model against the real process is a separate task that the simulation cannot do for itself.
Example Suppose a real event has probability but the model uses . With a million trials the standard error is , and Chebyshev’s inequality puts the estimate within of with probability at least . The gap of from the real value, about standard errors, remains. For an implementation error, take the event of two heads in two fair independent tosses, with probability . A program that draws one random bit and uses it for both tosses counts a success whenever that bit is heads, so it estimates , and more trials make that wrong answer more precise.
Check yourself
- A simulation estimates an event with true probability from 2500 independent trials. Find the standard error of the estimate and the number of trials that would halve it.
Show the answer
The standard error is
one percentage point. Halving it takes four times as many trials, so 10,000 trials, with standard error .
- A simulation of a rare event runs 400 independent trials and records no successes. Find the estimate and its plug-in standard error. Does the run show that the event has probability ? Find the probability of zero successes if the true probability were , and the conservative standard error for 400 trials.
Show the answer
The estimate is , and the plug-in standard error is . The run does not show that the probability is . If the true probability were , zero successes would have probability , so this outcome is not unusual for a positive probability, and the true standard error would be about , not . The conservative standard error is . It is a valid upper bound on the true standard error for every , but it describes the spread of the estimate, not a guaranteed limit on its error, and for a rare event it is very loose.
- A colleague reruns the seed 20261012 program five times, gets 2484 successes every time, and concludes that the estimate has no Monte Carlo error. The colleague also suggests running a million trials to fix a model whose event probability is known to be wrong. Explain what is wrong with each conclusion.
Show the answer
The reruns use the same generator and seed, so they reproduce the same sequence of draws. Identical output confirms reproducibility, but the five reruns are one run repeated, not five replications. The Monte Carlo error is still described by the standard error , and a genuine second run with seed 20261013 gave the different estimate . A million trials would shrink the standard error, but the estimate would converge to the probability in the wrong model, so the model error would remain. The model itself has to be corrected.