SECTION 1
Historical Context & Motivation
Some probability questions are easy to answer with a formula. What is the chance of rolling a 6 on a fair die? Simple: 1 out of 6. But what about the probability that a game of Monopoly ends in fewer than 200 turns, or the expected number of shuffles needed to randomly sort a deck of cards? These questions involve so many interacting variables that a neat closed-form solution either doesn't exist or would take pages of combinatorics to derive. For centuries, mathematicians searched for a practical shortcut, and they found one: simulation — running a random experiment many, many times and letting the results speak for themselves.
1777 • Buffon's Needle
1946 • The Monte Carlo Method
1970s • Personal Computers Emerge
Today • Simulation Everywhere
The central question this lesson addresses is straightforward: When an exact calculation is too complex, how can we use repeated random trials to approximate a probability or expected value? By the end of this lesson, you'll know how to design, run, and interpret simulations that answer questions the formulas can't easily handle.
SECTION 2
Core Principles & Definitions
Before you run a single trial, it helps to understand the key ideas that make simulation work. A simulation is a model of a real-world process that uses random numbers to mimic chance. Each complete run of the model is called a trial (or iteration), and the collection of all trials makes up the simulation. The power of the technique rests on a beautiful mathematical fact: as the number of trials grows, the simulated results converge to the true probability or expected value.
Random Number Generator (RNG)
Trial (Iteration)
Law of Large Numbers
Expected Value (E)
Simulated Probability
KEY TAKEAWAY
SECTION 3
Visual Explanation — The Law of Large Numbers in Action
The diagram below shows what happens when you simulate a coin flip. The true probability of heads is 0.50. Notice how the simulated proportion bounces wildly at first but gradually settles near the true value as the number of trials grows. This convergence is the Law of Large Numbers in action.
Key observation: at 10 trials the simulated proportion was about 0.30, which is way off. By 100 trials it hovered near 0.50, and by 1,000 trials it was nearly exact. This pattern holds for any simulation. The practical rule of thumb in this course is to use at least several hundred trials — and more is almost always better.
SECTION 4
Mathematical Framework
While simulation is about running experiments, a bit of mathematical notation helps you interpret the results. Two key formulas connect your simulation data to the quantities you want to estimate.
SIMULATED PROBABILITY
Where k is the count of successes (trials where the event of interest happened) and n is the total number of trials. As n → ∞, P̂ → P (the true probability).
SIMULATED EXPECTED VALUE
Where x₁, x₂, …, xₙ are the numerical outcomes of each trial. Ê is simply the sample mean of the trial results. By the Law of Large Numbers, Ê → E (the true expected value) as n grows.
THEORETICAL EXPECTED VALUE (FOR COMPARISON)
This formula gives the exact expected value by summing each possible outcome multiplied by its probability. When there are too many outcomes to enumerate, or when probabilities are unknown, simulation provides Ê as a practical substitute.
When should you simulate?
SECTION 5
Designing a Simulation — Step by Step
Every simulation follows a consistent design process. Whether you're using a graphing calculator, a spreadsheet, or a programming language, the five steps below remain the same. The diagram that follows turns these steps into a visual flowchart you can reference whenever you design your own simulation.
Let's unpack each step. In Step 1, you state the question precisely: "What is the probability that all five friends share a birthday month?" or "What is the expected number of rolls to get three sixes?" In Step 2, you pick a randomizer that matches the real situation. A coin works for 50-50 events; a random integer from 1 to 6 models a die; digits 0–9 from a random number table can model all sorts of outcomes. In Step 3, you spell out what one trial looks like: the sequence of random actions and the specific result you record. In Step 4, you repeat the trial many times (at least 100, ideally 1,000+). Finally, in Step 5, you calculate P̂ or Ê from your collected data and state your conclusion.
Common Random Devices
SECTION 6
Worked Example — The "At Least One Match" Problem
Suppose you buy a bag of 8 colored candies. Each candy is equally likely to be one of 5 colors: red, blue, green, yellow, or orange. What is the probability that you get at least one candy of every color? Counting the exact number of favorable outcomes requires advanced combinatorics (Stirling numbers). A simulation gives us a solid estimate much more easily.
Simulating the Candy Color Problem
- 1
Step 1 — Define the Question
We want to estimate P(all 5 colors appear in a bag of 8 candies), where each candy is independently and equally likely to be one of 5 colors. - 2
Step 2 — Choose a Random Device
We assign each color a digit: 1 = red, 2 = blue, 3 = green, 4 = yellow, 5 = orange. We use a calculator's randInt(1, 5) function (or pick digits 1–5 from a random number table, ignoring 0 and 6–9). - 3
Step 3 — Define One Trial
Generate 8 random integers from 1 to 5. Record whether all five distinct values (1, 2, 3, 4, 5) appear at least once. Mark the trial as a "success" if yes, "failure" if no. - 4
Step 4 — Run Many Trials
We ran 1,000 trials. Here is a snapshot of the first 5 trials: - 5
Step 4 (continued) — Sample Data
Trial 1: 3 1 5 2 2 4 1 3 → colors {1,2,3,4,5} → Success. Trial 2: 4 4 1 3 5 3 1 2 → colors {1,2,3,4,5} → Success. Trial 3: 2 2 1 1 3 3 2 1 → colors {1,2,3} → Failure. Trial 4: 5 4 3 1 2 5 3 4 → colors {1,2,3,4,5} → Success. Trial 5: 1 1 2 2 3 3 4 4 → colors {1,2,3,4} → Failure. - 6
Step 5 — Analyze Results
Out of 1,000 trials, suppose 537 were successes.P̂ = 537 / 1000 = 0.537. We estimate there is roughly a 54% chance of getting all 5 colors in a bag of 8 candies. (The exact answer via inclusion-exclusion is about 0.5355 — our simulation is very close!)
Expected Value Version
SECTION 7
Strengths, Limitations & Choosing the Right Approach
Simulation is incredibly versatile, but it isn't magic. Understanding when to simulate versus when to calculate exactly is an important skill. The table below summarizes the main trade-offs.
| Criterion | Simulation | Exact Calculation |
|---|---|---|
| Accuracy | Approximate; improves with more trials | Exact (if the formula is correct) |
| Ease of setup | Often easy — just model the experiment | Can be very difficult for complex scenarios |
| Speed | Needs many trials; fast on a computer, slow by hand | One calculation gives the answer immediately |
| Flexibility | Works for nearly any scenario, even non-standard ones | Requires a known formula or counting technique |
| Reproducibility | Results vary slightly each time (random) | Always gives the same answer |
Simulation vs. Exact Calculation — key trade-offs
KEY TAKEAWAY
SECTION 8
Connections to Advanced Topics
The simulation techniques you learn in this course are the foundation for much more powerful tools in college-level statistics, data science, and applied mathematics. Here is a brief comparison showing how the ideas you're mastering now connect to what lies ahead.
| What You Learn Now | Where It Leads |
|---|---|
| Running trials with dice, coins, or RNG | Monte Carlo methods used in physics, finance, and machine learning |
| Approximating P̂ by counting successes | Bayesian inference and Markov Chain Monte Carlo (MCMC) sampling |
| Estimating expected value Ê from averages | Bootstrap resampling for confidence intervals (AP Statistics and beyond) |
| Law of Large Numbers as justification | Central Limit Theorem and convergence theory in probability |
From this lesson to advanced probability and statistics
You don't need to master these advanced topics right now. The important point is that simulation is not a shortcut around "real" math — it is a powerful branch of mathematics in its own right. Many professional statisticians and scientists spend their entire careers refining simulation methods to solve problems that no formula can touch.
SECTION 9
Practice Problems
Question 1: CONCEPTUAL
Show answer
Question 2: BASIC CALCULATION
Show answer
Question 3: INTERMEDIATE
Show answer
Question 4: APPLIED
Show answer
Question 5: CRITICAL THINKING
Show answer
SUMMARY
Lesson Summary
Summary
A simulation uses repeated random trials to approximate a probability or expected value when exact computation is too complex. You design a simulation in five steps: define the question, choose a random device that matches the real situation, define one trial, run many trials, and analyze the data. The simulated probability P̂ = k/n (successes over total trials) and the simulated expected value Ê = (sum of outcomes)/n both converge to their true values as the number of trials increases.
The Law of Large Numbers is the mathematical backbone that guarantees convergence: more trials yield better approximations. Simulation is most valuable when the number of possible outcomes is huge, when multiple random events interact, or when no clean formula exists. Remember that simulation gives an approximate answer — different runs may produce slightly different results — but with enough trials, the approximation becomes remarkably accurate.