Historical Context & Motivation
For centuries, mathematicians solved probability problems with formulas—counting outcomes, multiplying fractions, and summing series. But some real-world questions are simply too tangled for a neat algebraic answer. Imagine trying to calculate the exact probability of winning a complex board game, or the expected number of boxes of cereal you need to buy to collect every toy inside. The formulas spiral into hundreds of terms, and one small mistake can wreck the entire answer.
The idea of using simulation—running random experiments many times and observing what happens on average—gave researchers a powerful shortcut. Instead of wrestling with impossible formulas, they could let randomness itself reveal the answer. This approach became especially practical once computers arrived, turning millions of random trials into a few seconds of work.
The central question this lesson addresses is: When a probability or expected-value calculation is too complex to solve by hand, how can running many random trials give us a reliable approximation?
Core Principles & Definitions
Before we dive into simulations, let's lock down the vocabulary. Expected value is the long-run average outcome of a random process—the number you'd approach if you could repeat the experiment forever. Simulation is a method of imitating a random process using a tool like a coin, die, random-number generator, or computer program. A single run-through of the process is called a trial, and the collection of all trials is called a simulation study. The more trials you run, the closer your simulated average gets to the true expected value—a fact guaranteed by the Law of Large Numbers.
Expected Value (EV)
Trial
Random-Number Generator (RNG)
Law of Large Numbers
Simulation Model
Visual Explanation — How a Simulation Converges
The diagram below shows what happens when you simulate rolling a fair six-sided die and track the running average after each trial. The true expected value of a single die roll is 3.5. Early on, the running average bounces wildly, but as you accumulate hundreds of trials, it settles closer and closer to 3.5. This visual pattern is the Law of Large Numbers in action.
This pattern holds for any random process—not just dice. Whether you're simulating free throws, lottery tickets, or genetics experiments, the running average of your simulated outcomes will settle toward the true expected value as you add more trials. The key insight is that more trials mean a more reliable estimate. A 10-trial simulation might be way off, but a 1,000-trial simulation will usually be very close to the true value.
Mathematical Framework
When you can list all outcomes, expected value is calculated with a formula. But when the situation is too complex for that formula, we replace it with a simulation estimate. Let's compare the two approaches side by side.
Designing a Simulation — Step by Step
Every simulation follows the same basic recipe. The challenge is adapting each step to your specific problem. Below is a flowchart that walks you through the process, followed by a detailed explanation of each stage.
- Define the Question. Clearly state what expected value or probability you want to estimate. Example: "What is the expected number of coin flips to get three heads in a row?"
- Build a Model. Decide how to represent the random process. For a coin, let 1 = heads and 0 = tails using a random integer generator. Each component of randomness must map correctly to outcomes.
- Run One Trial. Execute the model once from start to finish and record the result (the number you're tracking).
- Repeat Many Times. The more trials, the better your estimate. A minimum of 100 trials is typical for classroom work; professional simulations use millions.
- Analyze Results. For expected value, compute the mean of all trial results. For probability, divide the number of 'success' trials by the total number of trials.
- State Your Estimate. Report your answer clearly, noting how many trials you ran. For example: "Based on 500 trials, the estimated expected value is approximately 14.2."
Worked Example — The Cereal Box Problem
A cereal company places one of 5 different toy figures in each box. The toys are distributed equally (each toy has a 1/5 chance of being in any given box). How many boxes do you expect to buy to collect all 5 toys? This is a classic problem where the exact calculation exists but involves the harmonic series and gets messy. Simulation gives us a fast, reliable estimate.
Strengths & Limitations of Simulation
Simulation is incredibly flexible, but it's not magic. Understanding when it shines and where it falls short will help you choose the right tool for each problem.
| Aspect | Strengths | Limitations |
|---|---|---|
| Complexity | Handles problems with hundreds of interacting variables that have no closed-form formula. | The model must correctly represent the real situation; a flawed model gives misleading results. |
| Accuracy | With enough trials, the estimate converges to the true value (Law of Large Numbers). | Results are always approximate—never exact. Each run can give a slightly different answer. |
| Speed | Computers can run millions of trials in seconds, making even huge simulations practical. | By hand or on a basic calculator, running enough trials can be tedious and time-consuming. |
| Understanding | Building a simulation forces you to think carefully about the structure of the problem. | Simulation doesn't explain why an answer is what it is—it only tells you what it is approximately. |
| Randomness | Captures real-world unpredictability naturally. | A poor random-number generator (e.g., patterns in manual dice rolls) can bias results. |
Connection to Advanced Topics
The simulation techniques you're learning now are the foundation for some of the most important methods in advanced statistics and data science. As you move into AP Statistics, college-level courses, or real-world applications, you'll encounter more sophisticated versions of the same core idea: use randomness to approximate answers.
| What You Learn Now | Where It Leads |
|---|---|
| Simulating expected value with dice, coins, or RANDINT | Monte Carlo Integration — using random points to estimate areas, volumes, and integrals that are impossible to solve algebraically |
| Counting successes over N trials to estimate probability | Bootstrap Resampling — repeatedly sampling from data to estimate confidence intervals without knowing the population distribution |
| Law of Large Numbers (more trials → better estimate) | Central Limit Theorem — explains why simulation averages form a normal distribution and how to quantify the precision of your estimate |
| Building a model that maps random numbers to outcomes | Agent-Based Modeling — simulating entire systems (epidemics, ecosystems, economies) by programming individual "agents" with probabilistic rules |
The beautiful thing about these connections is that the logic never changes: generate random outcomes, repeat many times, and let the averages tell you the truth. The only thing that evolves is the complexity of the model and the power of the computing tools you use to run it.
Practice Problems
Lesson Summary
Simulation is a method for approximating expected value or probability by running many random trials of a process and averaging the results. The Law of Large Numbers guarantees that as the number of trials increases, the simulated average converges toward the true expected value. Every simulation follows the same six-step recipe: define the question, build a model that maps random numbers to outcomes, run one trial, repeat many times, analyze results (mean for expected value, proportion for probability), and state your estimate.
Simulation excels when the number of outcomes is too large to list, when stages of the process depend on each other, or when no clean formula exists. The most critical design decision is ensuring your simulation model faithfully represents the real-world situation—incorrect assumptions lead to incorrect estimates. When a theoretical formula is available, use it for an exact answer; when it's not, simulation provides a powerful and reliable approximation.