What is when ? An integral gives at once, but a computer can also estimate it by drawing many values of , squaring each one and averaging the squares. The same idea works for models where no formula is available, and the estimate becomes useful once we can say how far a simulated average is likely to land from its target. This lesson sets up the Monte Carlo estimator for expectations and probabilities, computes its standard error, and separates simulation error, which more draws reduce, from model error, which they do not.
Key terms
Monte Carlo method
Definition The Monte Carlo method estimates a probability or an expectation under a probability model by simulating draws from the model and averaging a summary of them. A Monte Carlo calculation has four parts, namely the target quantity, the probability model, the rule that generates draws and the rule that summarizes them. Computers produce pseudorandom numbers, a deterministic sequence fixed by an algorithm and a starting value called the seed, and use them in place of independent uniform draws. A run is reproducible when its generator and software version, seed, sample size, order of draws and the steps that turn draws into values are recorded.
In plain words Instead of computing an expectation with a sum or an integral, let the computer play out the random experiment many times and average the results. The law of large numbers is the reason this works. A simulation answers a question about the model. More draws make the estimate of the model’s value more precise, but they cannot show that the model fits the real process. A wrong rate, a wrong support or ignored dependence is a model error, which is separate from simulation error.
Example To estimate for , the target is , the model is the uniform law, each draw is a pseudorandom number , and the summary is the average of the squares . One recorded run in Python 3.12 used the Mersenne Twister generator random.Random with seed and took draws, one call of random() for each draw. Repeating the same steps with the same generator and seed reproduces its results exactly.
Monte Carlo estimator
Definition Let be a random variable from the model and a function with , and let . For independent draws , each with the distribution of , the Monte Carlo estimator is
It is unbiased, , and by the weak law of large numbers as for every . For a fixed it is a random variable, and each run produces one value of it.
In plain words Apply the function to each draw first and average afterward. The order matters. Averaging the values estimates , while squaring the average of the estimates , which is a different number.
Example For and the target is
The recorded run of draws gives , so the error of this run is . The same draws give , which is close to , not to .
Probability as an expected indicator
Definition For an event , the indicator equals when occurs and otherwise, so . A probability is therefore an expectation, and its Monte Carlo estimator is the fraction of draws in which the event occurs. For the event that falls in a set , with the indicator of ,
estimates .
In plain words Score each draw if the event happens and if it does not, and average the scores. The result is a relative frequency in a finite simulation, an estimate of the model probability rather than the probability itself. A run with no occurrences gives the estimate , which does not show that the event has probability .
Example Under the uniform model the event has probability . Of the same recorded draws, exceed , so . The squares and the indicators come from the same draws, so the two estimates from this run are not independent of each other.
Monte Carlo standard error
Definition Suppose the draws are independent and is finite. Then
The Monte Carlo standard error is this standard deviation of the estimator across repeated independent runs of the same size. For an indicator . When is unknown it is estimated, by the sample standard deviation of the values , or by for an indicator, and the estimated standard error is itself random.
In plain words The standard error tells how much the estimate would vary from run to run. It is not a bound on the error of a particular run, which can exceed one standard error and now and then two. The formula needs independent draws and a finite variance, and it measures sampling variability within the model, not whether the model is right.
Example For the fourth moment gives
With the standard error is , and the run’s error of is about standard errors, which is compatible with ordinary run-to-run variation. For the event the standard error is , and the estimate is about standard errors below . The estimated version is close to the exact one.
Square-root cost of precision
Definition Suppose . Because , multiplying the number of independent draws by a factor divides the standard error by . Halving the standard error takes four times as many draws, and a tenfold reduction takes one hundred times as many. A target standard error is reached exactly when . If , every value equals with probability and the standard error is for every .
In plain words Precision gets expensive. Doubling the draws shrinks the standard error only by the factor . The rule describes the spread of the estimator, so a particular run with four times as many draws need not have half the error of a particular smaller run.
Example For the standard error is about with draws, with draws and with draws. For the event , a standard error of needs
draws.
Approximate interval for a Monte Carlo estimate
Definition If the draws are independent and , the central limit theorem says that converges in distribution to . For large this motivates the approximate percent interval
with replaced by an estimate when it is unknown. Its coverage over repeated runs is close to when is large, but it is not guaranteed at a fixed . With the exact standard error, Chebyshev’s inequality gives a guarantee for every and every ,
In plain words When the normal approximation is good, about percent of runs produce an interval that covers the target. A particular interval either contains or it does not, and the percent describes the procedure. The interval accounts for simulation error only, so a precise interval for a wrong model is still wrong about the real process.
Example For the recorded run, runs from about to and contains . For the event, runs from about to and contains . Chebyshev’s inequality with bounds the miss probability by , and for the squared-uniform estimate it gives the wider interval , from about to .
Check yourself
- A study estimates for from independent draws. Find the standard error of the estimate for , and the number of draws that gives a standard error of .
Show the answer
The indicator of has variance , so for the standard error is
A standard error of is half of that, so it takes four times as many draws, . The condition gives the same answer.
- A Monte Carlo study estimates for with independent draws. Find the target, the variance of one value , and the standard error for draws. How many draws halve that standard error?
Show the answer
The target is . The second moment of is the sixth moment of , , so
For draws the estimator has variance , so the standard error is . Halving it takes four times as many draws, , which give a standard error of about .
- A simulation of independent draws sees no occurrence of an event, and a report states that the event has probability with standard error . What is wrong with this report?
Show the answer
The estimate is a relative frequency, not the model probability, and the plug-in standard error is only because it replaces the unknown by . Small positive probabilities easily produce a run with no occurrences. For the chance of seeing none in independent draws is , and every up to about gives that outcome a chance of at least percent. The report should state the count, occurrences in draws, and should not claim that the probability is or that the estimate is exact.