MATH 3 • STATISTICS & PROBABILITY

Simulating Expected Value — I can use simulation to approximate expected value or probability when computation is complex.

When the math gets messy, let random trials do the heavy lifting.

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.

1777
Buffon's Needle Problem
Comte de Buffon proposed dropping a needle onto a lined surface to estimate π. This was one of the earliest examples of using a random physical experiment to approximate a mathematical value.
1946
The Monte Carlo Method
Stanislaw Ulam, while recovering from illness and playing solitaire, realized that running many random trials could solve complex nuclear-physics calculations. He and John von Neumann named the method after the Monte Carlo casino.
1960s
Computer-Driven Simulations
As computers became widely available, scientists in fields from finance to weather forecasting began using millions of random trials to predict outcomes that were too complex for exact formulas.
Today
Simulation Everywhere
From video-game AI to medical research, simulation is a standard tool. Spreadsheets, graphing calculators, and free coding platforms let students run thousands of trials in seconds.

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.

1

Expected Value (EV)

The weighted average of all possible outcomes, where each outcome is multiplied by its probability. When computation is straightforward, you can find EV with a formula. When it's not, simulation steps in.
2

Trial

One complete run-through of the random process you're modeling. For example, if you're simulating rolling two dice and summing them, one trial = one pair of rolls.
3

Random-Number Generator (RNG)

A tool—physical or digital—that produces unpredictable numbers. Dice, coins, spinner apps, and spreadsheet functions like RAND() are all examples.
4

Law of Large Numbers

A theorem stating that as the number of trials increases, the sample mean converges toward the true expected value. This is the mathematical backbone of simulation.
5

Simulation Model

The set of rules that maps random numbers to outcomes in your experiment. Designing this model correctly is the most important step in any simulation.
KEY TAKEAWAY
Think of simulation like taste-testing a giant pot of soup. You can't drink the whole pot to know the flavor, but if you stir it well and take many small spoonfuls from different spots, you'll get a very accurate idea of the taste. Each spoonful is a trial, the stirring is the randomness, and the overall flavor you sense is the expected value.

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.

The cyan line represents the running average of simulated die rolls. Notice how it fluctuates dramatically in the first 20–30 trials (left side) but stabilizes near the pink dashed line (EV = 3.5) as the number of trials grows. This convergence is precisely what the Law of Large Numbers predicts.

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.

THEORETICAL EXPECTED VALUE
E(X) = x₁ · P(x₁) + x₂ · P(x₂) + … + xₙ · P(xₙ)
Each xᵢ is a possible outcome, and P(xᵢ) is its probability. This works perfectly when you know every outcome and its probability—like rolling a single die.
SIMULATED EXPECTED VALUE
E(X) ≈ (1/N) × (result₁ + result₂ + … + resultₙ)
N is the total number of trials. Each resultᵢ is the outcome recorded in trial i. As N → ∞, this average approaches the true E(X).
SIMULATED PROBABILITY
P(event) ≈ (number of trials where event occurs) / N
To estimate a probability through simulation, count how many of your N trials produce the event you care about, then divide by N. The more trials you run, the closer this fraction gets to the true probability.
💡 When Should You Simulate?
Use simulation when: (1) the number of possible outcomes is enormous or hard to list, (2) outcomes depend on each other in complicated ways, or (3) the probability model involves multiple stages that make a formula impractical. If the problem has a simple formula—use it! Simulation is a tool for complexity, not a replacement for basic math.

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.

Follow these six stages for any simulation problem. The most critical step is Step 2: Build a Model—your random-number assignments must match the real probabilities of the situation.
  1. 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?"
  2. 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.
  3. Run One Trial. Execute the model once from start to finish and record the result (the number you're tracking).
  4. Repeat Many Times. The more trials, the better your estimate. A minimum of 100 trials is typical for classroom work; professional simulations use millions.
  5. 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.
  6. 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.

Simulating the Cereal Box Collector Problem
1
Step 1 — Define the QuestionWe want to estimate the expected number of cereal boxes a person must buy to collect all 5 different toys.
2
Step 2 — Build the ModelUse a random integer from 1 to 5 (each equally likely) to represent which toy is in a box. In a spreadsheet or calculator, this is RANDINT(1, 5). One trial consists of generating random integers until all five values (1, 2, 3, 4, 5) have appeared at least once. The result of each trial is the count of integers generated.
3
Step 3 — Run One Trial (Example)Suppose the random integers come out: 3, 1, 3, 5, 2, 5, 1, 4. We needed 8 boxes to see all five toys. So the result of this trial is 8.
Trial 1 result: 8 boxes
4
Step 4 — Repeat Many TimesWe run 20 trials (a small number for illustration). Suppose our results are: 11, 8, 15, 7, 13, 10, 9, 6, 14, 12, 8, 11, 19, 10, 7, 13, 16, 9, 11, 14.
5
Step 5 — Analyze ResultsSum of all results: 11 + 8 + 15 + 7 + 13 + 10 + 9 + 6 + 14 + 12 + 8 + 11 + 19 + 10 + 7 + 13 + 16 + 9 + 11 + 14 = 223. Divide by 20 trials: 223 ÷ 20 = 11.15.
Simulated E(X) ≈ 11.15 boxes
6
Step 6 — Interpret and CompareThe exact theoretical answer (using the formula 5 × (1 + 1/2 + 1/3 + 1/4 + 1/5)) is 5 × (137/60) ≈ 11.42. Our 20-trial estimate of 11.15 is already close! With 1,000 trials, we'd typically land within about 0.1 of the true value.
Theoretical E(X) ≈ 11.42 — our estimate is within 2.4% after just 20 trials

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.

Strengths and limitations of using simulation to estimate expected value
AspectStrengthsLimitations
ComplexityHandles 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.
AccuracyWith 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.
SpeedComputers 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.
UnderstandingBuilding 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.
RandomnessCaptures real-world unpredictability naturally.A poor random-number generator (e.g., patterns in manual dice rolls) can bias results.
KEY TAKEAWAY
Simulation is like using GPS navigation instead of calculating your route on a paper map. GPS doesn't give you the exact shortest path every time—traffic changes, and different runs might suggest slightly different routes—but it consistently gets you close to the best answer with very little effort. When the road network is simple, you might plan the route yourself. When it's a tangled city with one-way streets and construction, you hand it to the GPS. Similarly, use exact formulas when the math is manageable, and simulation when it's not.

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.

How today's simulation skills connect to advanced methods
What You Learn NowWhere It Leads
Simulating expected value with dice, coins, or RANDINTMonte Carlo Integration — using random points to estimate areas, volumes, and integrals that are impossible to solve algebraically
Counting successes over N trials to estimate probabilityBootstrap 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 outcomesAgent-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

PROBLEM 1CONCEPTUAL
A student runs a simulation with 50 trials and gets an estimated expected value of 7.2. Another student runs the same simulation with 5,000 trials and gets 6.85. The true expected value is 6.83. Explain why the second student's estimate is more reliable, even though both students used the same process.
PROBLEM 2BASIC CALCULATION
You simulate a game by rolling a die 10 times. The results of your 10 trials are: 4, 2, 6, 1, 3, 5, 6, 2, 4, 3. Use these results to estimate the expected value of a single die roll. How does your estimate compare to the theoretical expected value of 3.5?
PROBLEM 3INTERMEDIATE
You want to estimate the probability that at least two people in a group of 10 share the same birthday (ignoring leap years). Describe how you would set up a simulation to approximate this probability. Be specific about what a single trial looks like, what you record, and how you compute the final estimate.
PROBLEM 4APPLIED
A basketball player makes 70% of her free throws. In a game, she shoots 5 free throws. You run a simulation using RANDINT(1, 10): numbers 1–7 represent a make, and 8–10 represent a miss. After 200 trials, she made all 5 free throws in 33 of them. Estimate the probability that she makes all 5 free throws. Then compare your answer to the exact calculation: (0.7)⁵.
PROBLEM 5CRITICAL THINKING
A friend designs a simulation to estimate the expected number of coin flips to get two heads in a row. In their model, they flip until they get a head, record the number of flips, then flip again until they get a head again, and add the two counts together. Explain why this model is flawed. What should the correct model look like instead?

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.

Varsity Tutors • Math 3 • Simulating Expected Value