A simulation imitates a chance process using a controlled random mechanism. It is useful when a probability is difficult to calculate directly or when you want to see how much a statistic varies under a stated model. The quality of the estimate depends on whether the simulation faithfully represents the process.
Define one trial before generating randomness
Specify the event or statistic you want to study, the model assumptions, and the steps that constitute one complete trial. Assign random outcomes in proportions matching the model. Then repeat independent trials and record the outcome of interest each time.
A trial may contain several random draws. Confusing one draw with one trial is a common design error. For example, studying the probability of at least two successes in five attempts requires five simulated attempts per trial, followed by one yes-or-no trial result.
Example: simulate a 30% success probability
Suppose each independent shot has success probability 0.30. To estimate the probability of at least two successes in five shots, use random digits 0 through 9, with 0, 1, and 2 representing success and the other seven digits failure.
Read five digits per trial, count successes, and record whether the count is at least two. If 472 of 1,000 independent trials meet the event, estimate its probability as
The digit assignment uses three equally likely digits out of ten, matching 30%. Assigning “odd means success” would model 50%, a different process. Reusing a digit within a trial is appropriate here because the attempts are modeled as independent with unchanged success probability.
Replacement rules encode dependence
If drawing cards without replacement, a simulation must remove each selected card from the available set until the trial ends. Independent draws with replacement would give the wrong probabilities because the composition changes after each draw.
Conversely, if each real trial begins with a fresh deck or restored population, reset the simulation between trials. The within-trial dependence and between-trial independence should match the actual situation.
For a random-digit mapping to unequal categories, use enough equally likely outcomes to represent the probabilities accurately. If a mapping cannot be exact, state the approximation rather than silently changing the model.
The law of large numbers explains stabilization
For independent trials with the same success probability p, the long-run relative frequency of success tends toward p as the number of trials grows. More trials generally make the simulation estimate more stable.
The law does not mean that a short run must balance itself immediately. After several failures, the next independent trial still has success probability p. Expecting “a success is due” is the gambler's fallacy.
Nor does the law guarantee that every larger simulation is closer than every smaller one. Random fluctuations remain; the overall tendency is toward greater stability with more trials.
Example: use simulation to judge an unusual result
Suppose a fair-coin model is proposed, and 16 heads are observed in 20 flips. Simulate many sets of 20 fair flips, recording the number of heads in each set. To estimate a one-sided probability for unusually many heads, count simulated sets with at least 16 heads.
If the scientific question concerns either unusually many heads or unusually many tails, the event must reflect both directions. Decide the direction from the question before examining the observed outcome, rather than choosing whichever tail looks more impressive afterward.
A small simulated tail proportion suggests the observed result is unusual under the model. It does not prove the model impossible, and it is not the probability that the model itself is true.
Report a simulation so someone can repeat it
State the random mechanism, mapping, trial structure, number of trials, recorded statistic, and estimated probability. A fixed random seed can make a computer simulation reproducible, but the seed is not a substitute for a correct model.
If an event occurs zero times, report an estimated frequency of zero in the simulated trials, not a proof that its true probability is zero. Rare events need many trials for stable estimation.
Try it yourself
Design a simulation for the probability that a family with four children has exactly three girls, assuming independent births with girl probability 0.5.
Answer: Use four fair coin flips per trial, mapping heads to girl. Record whether exactly three heads occur. Repeat many independent four-flip trials and divide the number of successful trials by the total trials. The trial is the four-child family, not one birth.
What to remember
Model the probabilities and dependence correctly, define a complete trial, and repeat it many times. Long-run stabilization does not make short-run outcomes self-correcting.