In a constructed model, a delay is either 0 or 4 minutes, each with probability one half, independently from one observation to the next. What does the average of four such delays look like across many samples? The binomial distribution gives the exact answer, and a simulation can produce ten thousand averages to set beside it. This lesson carries out both, compares them honestly, and keeps the number of observations in one sample separate from the number of times the whole sample is repeated.
Key terms
Repeated sampling
Definition Fix a sampling procedure, here drawing a random sample from a model and computing a statistic . Repeated sampling carries out the whole procedure times with fresh random inputs, giving values , one per repetition. When the repetitions are independent, are independent and identically distributed, each with the sampling distribution of .
In plain words Each repetition draws a whole new sample and records one value of the statistic. Taking one sample and copying its average thousands of times is not repeated sampling, and neither is reusing the same draws in several repetitions.
Example In the delay model each equals or minutes with probability each, the observations are independent, the sample size is and the statistic is
For this lesson the procedure was actually run times in Python 3.12 with the generator random.Random(20261014). Each uniform draw from random() below gave a delay of and every other draw gave . Consecutive groups of four among the 40,000 draws formed the 10,000 samples, and each sample gave one recorded mean.
Exact benchmark
Definition An exact benchmark is a quantity derived exactly from the model before the simulation output is examined, such as the distribution of the statistic, its mean and variance, or the probability of an event, and then used as the reference for that output. Agreement with a benchmark, up to simulation error, supports the claim that the program carries out the stated model but does not prove it. It does not check that the model describes a real process.
In plain words Work out what the answer should be, wherever that is possible, before looking at simulated numbers. A mismatch much larger than the standard error then points to a mistake in the program or in the benchmark calculation, and a match is evidence about the program, not about the real-world assumptions behind the model.
Example Let be the number of observations equal to in one sample. Then , the total delay is , and so .
One delay has mean and variance , so and . The table agrees, since the squared deviations , , , and from , weighted by the probabilities, give . Two benchmark event probabilities are and .
Empirical distribution
Definition For recorded values , the empirical distribution assigns to each value the relative frequency , where is the number of repetitions with . It is a probability distribution, with nonnegative values that add to , but it is computed from one finite run. It approximates the sampling distribution and generally differs from it.
In plain words The empirical distribution is the histogram of the output, scaled so that the bars add to one. It varies from one independent run to another, while the exact distribution stays fixed.
Example The recorded counts of the sample means to were 647, 2447, 3782, 2491 and 633, which add to 10,000.
| Count | 647 | 2447 | 3782 | 2491 | 633 |
| Empirical | 0.0647 | 0.2447 | 0.3782 | 0.2491 | 0.0633 |
| Exact | 0.0625 | 0.25 | 0.375 | 0.25 | 0.0625 |
The largest difference is , at . That is ordinary for 10,000 repetitions, since a relative frequency estimating has standard error .
Empirical variance
Definition The empirical variance of recorded values with average is the variance of their empirical distribution,
with denominator . The sample variance with denominator is a different statistic, so a report should say which one it uses.
In plain words The empirical variance describes the spread of the recorded output itself. It is computed like any variance, with the relative frequencies in the role of probabilities. For the sample variance equals the empirical variance times , so for large the two are close, and they are equal only when every recorded value is the same.
Example The recorded means have sum , and their squares have sum . Dividing by ,
The exact values are and . The average misses by , small next to the standard error of an average of 10,000 independent sample means. With denominator the variance would be about .
Replication count
Definition The replication count is the number of independent repetitions of the whole experiment. It differs from the sample size , the number of observations inside one repetition. The sample size decides which distribution is being studied, for example through , while decides how precisely the simulation estimates that distribution. An estimate of the probability of an event about the statistic averages independent indicators, one per repetition, so its standard error is .
In plain words More observations per sample make each average less variable. More repetitions estimate the distribution of the averages more precisely. The total number of random draws, , counts inputs, and when putting it in place of in a standard error makes the simulation look more precise than it is.
Example The event occurred in of the 10,000 repetitions, an estimate of against the exact . Its standard error is
Treating the 40,000 draws as repetitions would give about , half the correct value. Changing the sample size changes the target instead. With the sample mean takes the values , and with probabilities , and , and its variance is rather than .
Check yourself
- Use the recorded table to estimate and compare it with the exact value. Does the agreement show that delays in a real service follow the 0 or 4 model?
Show the answer
The estimate is , and the exact probability is . The difference is smaller than the standard error
so the run is consistent with a program that carries out the model. It does not show that real delays follow the model. The simulation explores consequences of the stated assumptions, and whether real delays take the values 0 and 4 with equal probability, independently, has to be checked with real data. Running the same program with the same seed again would reproduce 3782 exactly, which confirms the computation but is not a new replication.
- Change the probability of a 4-minute delay to , keeping independence and four observations per sample. Find the exact distribution of , its mean and variance, and . Can the recorded counts serve as a simulation of this new model?
Show the answer
The sample mean still equals the count of 4-minute delays, now with . So
for , which gives , , , and over . The mean is and the variance is . The event has probability . The recorded counts cannot serve, because they come from the model with probability . These answers are exact theoretical values, and a new simulation of the changed model would have to be run and compared with this new benchmark.
- A report estimates as with standard error , arguing that 40,000 random draws were made. What is wrong, and what is the correct plug-in standard error?
Show the answer
The event concerns one sample mean, so there is one indicator per repetition, and the estimate averages independent indicators. The 40,000 draws are inputs, four for each indicator, and they are not separate trials of the event. The correct plug-in standard error is
twice the reported value, because . Using the draw count understates the Monte Carlo error.