Tutorials › Introduction to Statistics › Simulation as a Probability Experiment

Simulation and Probability Models · Tutorial 375 of 996

Simulation as a Probability Experiment

Understand how repeated computer-generated outcomes approximate a model probability, and why the simulation model is not the real process it represents.

Beginner 9 min read

What You'll Learn

  • Explain what a probability simulation represents and what it leaves out.
  • Describe how repeated simulated outcomes relate to long-run relative frequency.
  • Identify assumptions in an independent fair-coin model.
  • Calculate and interpret a simulated relative frequency.
  • Explain why simulation results vary and may differ from both the model probability and real outcomes.

From a Chance Question to a Simulation

A probability model gives a mathematical description of uncertain outcomes. A simulation uses random, computer-generated outcomes that follow that model to imitate the chance process repeatedly. By recording how often a chosen event occurs, we can see the event’s relative frequency under the model. The important qualification is under the model: a simulation does not recreate every detail of a real-world process or prove that the model describes it perfectly.

For a familiar example, suppose we represent a coin toss by a model with two possible outcomes, heads and tails, each with probability \(0.5\). The model also treats successive tosses as independent: knowing the outcome of one toss does not change the probabilities for the next. A computer can generate outcomes according to these rules. Repeating that operation produces simulated sequences of tosses that we can summarize and compare with the model’s probabilities.

Definition: A simulation is a process that generates outcomes according to a specified probability model in order to imitate a chance process and study the results. A simulated relative frequency is the number of simulated occurrences of an event divided by the number of times the simulation was run.

The model must be stated before its simulated outcomes can be interpreted. For an ideal fair-coin model, the assumptions are that each toss has outcomes heads and tails with probability \(0.5\), and that different tosses are independent. A physical coin may not meet these assumptions exactly. Its shape, how it is tossed, and the surface on which it lands are among the details the simple model leaves out. The simulation follows the assumptions we specify; it does not inspect or correct them.

What Repeated Simulation Tells Us

Consider an event \(A\), such as “the next toss is heads.” Its model probability is \(P(A)=0.5\). If we simulate many tosses and calculate the fraction that are heads, that fraction may be above or below \(0.5\). A finite simulation is random, so it will usually not match the model probability exactly. Repeating the simulation gives more opportunities for the fraction to reflect the model’s long-run behavior, but it does not make each batch’s result predictable in advance.

This connection between probability and long-run relative frequency can be justified directly. Suppose \(n\) simulated tosses are independent and each has probability \(p\) of producing the event of interest. Define \(Y_i=1\) when the event occurs on simulated toss \(i\), and \(Y_i=0\) otherwise. The simulated relative frequency is the average of these indicators:

$$ \hat{p}_{\text{sim}}=\frac{Y_1+Y_2+\cdots+Y_n}{n} $$

Each \(Y_i\) has mean \(p\) and variance \(p(1-p)\). Independence means the variances of the \(Y_i\) add, so the average has mean \(p\) and variance \(p(1-p)/n\):

$$ E(\hat{p}_{\text{sim}})=\frac{np}{n}=p, \qquad \operatorname{Var}(\hat{p}_{\text{sim}}) =\frac{np(1-p)}{n^2} =\frac{p(1-p)}{n} $$

As \(n\) grows, the variance \(p(1-p)/n\) decreases. This is a mathematical reason to expect the relative frequency to cluster more closely around \(p\) over larger runs, though any particular run can still be unusually high or low. For example, Chebyshev’s inequality gives

$$ P\left(\left|\hat{p}_{\text{sim}}-p\right|\geq \varepsilon\right) \leq \frac{p(1-p)}{n\varepsilon^2} $$

for any \(\varepsilon>0\). The bound gets smaller as \(n\) increases. It describes a probability over repeated simulations, not a promise that every larger batch will be closer to \(p\) than every smaller batch.

Worked Examples

Worked Example: Simulating Heads on a Fair Coin

A computer generates 20 tosses from an independent fair-coin model. In one hypothetical run, 11 of the outcomes are heads and 9 are tails. Find the simulated relative frequency of heads and interpret it.

The model assigns probability \(0.5\) to heads on each toss. The observed simulated relative frequency is the number of heads divided by the number of simulated tosses:

$$ \hat{p}_{\text{sim}}=\frac{11}{20}=0.55 $$

In this run, heads occurred on 55% of the simulated tosses. The result is 0.05 above the model probability of 0.5, but that difference does not show that the simulation failed. Random variation can produce a batch with more heads than tails. Nor does the result mean that the next simulated toss has probability 0.55 of being heads: under the specified model, that probability remains 0.5.

Worked Example: Simulating a Coin Model With Unequal Probabilities

Suppose a model assigns probability \(0.7\) to heads and probability \(0.3\) to tails on each independent toss. A computer generates 50 tosses from this model, and a hypothetical output contains 34 heads. Calculate and interpret the simulated relative frequency.

The event being counted is heads, and the number of simulated tosses is 50:

$$ \hat{p}_{\text{sim}}=\frac{34}{50}=0.68 $$

Heads occurred on 68% of the simulated tosses, compared with a model probability of 70%. The simulated fraction differs from \(0.7\) by \(0.02\). That modest difference is compatible with random variation in a finite run. The model says what probability the computer uses for each toss; \(0.68\) is the fraction observed in this particular set of 50 simulated outcomes.

If this model is meant to represent a physical coin, the distinction matters. The output establishes what happened in the simulation, not what would happen with the real coin. Whether the \(0.7\) model is appropriate depends on the real process and how well its assumptions represent that process.

Worked Example: Simulating an Event Across Three Tosses

Use an independent fair-coin model to study the event “at least one head occurs in three tosses.” A hypothetical computer run generates 100 groups of three tosses, and 89 groups contain at least one head. Find the simulated relative frequency and compare it with the model probability.

First find the model probability. The event’s complement is “all three tosses are tails.” By independence, that complement has probability \(0.5^3=0.125\). Therefore:

$$ P(\text{at least one head}) =1-P(\text{all tails}) =1-(0.5)^3 =0.875 $$

The simulated relative frequency is:

$$ \hat{p}_{\text{sim}}=\frac{89}{100}=0.89 $$

In this run, the event occurred in 89% of the simulated groups, compared with a model probability of 87.5%. The simulated result is \(0.89-0.875=0.015\), or 1.5 percentage points, higher. This is a difference between one random run and the probability specified by the model; it does not change the model probability or guarantee that another run will be closer.

The Model Is Not the Real Process

A simulation is useful because it lets us explore the consequences of a model by generating many possible outcomes. Its strength is also its limitation: the computer follows the rules it was given. If a real process has dependence between outcomes, unequal probabilities, or possible outcomes omitted from the model, the simulation will not represent those features unless they are included in its rules.

For a physical coin, an independent fair-coin model is a simplification. It treats each toss as having the same two possible results, assumes each has probability \(0.5\), and assumes one toss does not affect another. The simulated outcomes follow those assumptions by design. Observing that the simulated fraction of heads is near \(0.5\) therefore tells us that the results are consistent with the model’s expected long-run behavior; it does not independently verify that a physical coin is fair.

It is also important to distinguish the model probability from the simulated relative frequency. The model probability is specified in advance. The relative frequency is calculated after a particular set of generated outcomes is observed. Repeated simulation provides a way to explore what the model can produce and how its event frequencies behave, not a way to turn a model assumption into a fact about the world.

Common Mistake: Expecting Every Batch to Match

A common mistake is to reason, “The probability of heads is \(0.5\), so exactly half of any 20 simulated tosses must be heads.” The probability model does not require an exact split in a finite batch. For example, 11 heads out of 20 gives a relative frequency of \(0.55\), as in the first worked example. That outcome is possible under the model.

The correction is to treat \(0.5\) as the probability assigned to each toss and as the center of the long-run relative-frequency behavior under the stated assumptions. A particular batch may differ from it. Even when batches become larger, relative frequencies need not move steadily toward \(0.5\); a later batch can be farther away than an earlier one.

Key takeaway: A simulation generates outcomes from a probability model. Repeated relative frequencies can illustrate that model’s long-run behavior, but each finite run varies, and a simulated result describes the model—not automatically the real process it represents.

Check Your Understanding

Use the distinction between a model probability and a simulated relative frequency in your answers.

  1. A hypothetical simulation generates 40 independent tosses from a fair-coin model, with 23 heads. What is the simulated relative frequency of heads, and how does it compare with the model probability?
  2. Why does a result of 23 heads in 40 tosses not change the probability of heads specified by a fair-coin model?
  3. A computer simulates 80 groups of three independent fair-coin tosses. In 71 groups, at least one head occurs. What is the simulated relative frequency for that event?
  4. Name two assumptions in the independent fair-coin model that may simplify the description of a physical coin-tossing process.
  5. Explain why a simulated relative frequency close to \(0.5\) does not by itself establish that a real coin is fair.