01 / 20

Simulation for
Probability

Learn how to use random simulations to estimate probabilities when theoretical calculations are complex or impossible.

College Statistics

What Is a Simulation?

A simulation is a method that uses random number generation to imitate a real-world process or experiment many times. Instead of computing a probability with formulas, we run the experiment thousands of times and observe how often the event of interest occurs.

Why Use Simulation?

Complex Problems
Many real situations have no clean formula: what is the chance of getting at least 3 heads in a row in 10 flips?
Verification
Even when a formula exists, simulation provides an independent check on your theoretical answer.
Flexibility
Simulations adapt easily: change rules, add conditions, or model entirely new scenarios with minimal effort.

Key Vocabulary

1
Trial: A single run of the random experiment (e.g., flipping a coin 10 times).
2
Outcome: The result of one trial (e.g., HHTTHHTTHH).
3
Event of interest: The specific condition we are counting (e.g., "at least 7 heads").
4
Repetitions (\( n \)): The total number of trials. More repetitions yield a more precise estimate.

The Law of Large Numbers

The mathematical foundation of simulation: as the number of trials \( n \to \infty \), the relative frequency of an event converges to its true probability.

0 0.5 1.0 0 250 500 750 1000 Number of Trials (n) Relative Freq. P = 0.5

Formal Estimation Framework

Given a random experiment with event \( A \):

The margin of error for a simulation-based proportion estimate with \( n \) trials is approximately:

Simulation vs. Theoretical

Simulation Theoretical
Approach Run experiment many times Apply formulas / counting rules
Result type Estimate (approximation) Exact value
When useful Complex or no formula available Simple, well-defined sample spaces
Precision Improves with more trials Always exact
Requires Random number generator Mathematical derivation

How to Design a Simulation

1
Describe the component: Identify the simplest random action (e.g., one coin flip, one die roll, picking a card).
2
Assign outcomes: Map real outcomes to numbers. For a fair coin: 0 = Tails, 1 = Heads.
3
Define one trial: Specify how many components make up a single trial (e.g., flip 10 coins).
4
State the response variable: What do you record? (e.g., number of heads, whether the event occurred).
5
Run many trials: Repeat at least \( n = 1{,}000 \) times and compute \( \hat{P} = k / n \).

Choosing a Random Device

The random device must match the real-world probabilities. Common mappings:

Coin Flip
Models any 50/50 event: boy/girl, win/lose with equal odds. Use 0 and 1.
Random Digits (0-9)
Each digit equally likely. Use subsets for unequal probabilities: digits 0-6 for \( P = 0.7 \).
Random Integers
Generate integers 1 to \( k \). Model die rolls, card draws, or any discrete uniform distribution.

Example 1: Coin Flips

Problem: Estimate the probability of getting exactly 3 heads in 5 fair coin flips.

Trial 1: H T H H T → 3 heads ✓ Event Trial 2: T T H T H → 2 heads ✕ Not event Trial 3: H H T H T → 3 heads ✓ Event . . . After 1000 trials: 312 had exactly 3 heads

Example 2: Free Throw Streaks

Problem: A basketball player makes 75% of free throws. Estimate the probability she makes at least 8 out of 10 free throws.

1
Component: One free throw. Use random digits 0-9: digits 0-7 = make, digits 8-9 = miss (since \( P = 0.75 \) is close to \( 0.8 \); alternatively, use integers 1-100 with 1-75 = make).
2
One trial: Generate 10 random integers from 1 to 100. Count how many are \( \leq 75 \).
3
Response variable: Did she make \( \geq 8 \)? Record "yes" or "no."
4
Run \( n = 5{,}000 \) trials. Suppose 2,814 resulted in \( \geq 8 \) makes.

Example 3: The Birthday Problem

Problem: In a room of 23 people, what is the probability that at least two share a birthday? This is famously counterintuitive: simulation makes it tangible.

Generate 23 random days (1-365) Any duplicates? Yes → 1 No → 0 Repeat 10,000 times 5,073 trials had a match → P ≈ 0.507

Visualizing Simulation Results

After running a simulation, we build a histogram of the response variable to see the distribution. Below: results of simulating "number of heads in 10 fair coin flips" for \( n = 5{,}000 \) trials.

Frequency Number of Heads 0 400 800 1200 0 1 2 3 4 5 6 7 8 9 10

Using a Random Digit Table

On the AP exam, you may be given a random digit table and asked to carry out a simulation by hand. Here is a sample row:

6 5 0 7 2 3 1 9 8 4 0 3 7 1 6 5 2 8 4 9 Line 107
1
Decide your mapping. For \( P = 0.3 \): digits 0, 1, 2 = success; digits 3-9 = failure.
2
Read digits one at a time. First 5 digits for one trial: 6, 5, 0, 7, 2 → successes at positions 3 and 5 → 2 successes.
3
Continue for each trial and tally results across all trials.

How Many Trials Are Enough?

More trials means a more precise estimate. The relationship between \( n \) and precision:

Trials \( n \) Margin of Error \( \approx 1/\sqrt{n} \) Reliability
100 \( \approx 0.10 \) Rough sketch
1,000 \( \approx 0.032 \) Reasonable estimate
10,000 \( \approx 0.01 \) High precision
100,000 \( \approx 0.003 \) Very high precision

Common Mistakes

✕ Wrong Probability Mapping
Assigning digits 1-7 for \( P = 0.7 \) but forgetting digit 0. Use 0-6 for 7 out of 10 digits, or use integers 1-100.
✕ Too Few Trials
Running only 20-50 trials and trusting the result. With \( n = 20 \), the margin of error is \( \approx 0.22 \): essentially useless.
✕ Not Defining One Trial
Confusing a single component (one flip) with a complete trial (10 flips). Always state what constitutes one trial clearly.

Question 1 of 5

A student simulates 2,000 trials of an experiment and finds that the event of interest occurred 460 times. What is the estimated probability of the event?

Question 2 of 5

A simulation uses random digits 0-9 to model a spinner where the probability of landing on "blue" is 0.4. Which digit assignment correctly models "blue"?

Question 3 of 5

To reduce the margin of error of a simulation estimate from 0.05 to 0.025, how should you change the number of trials?

Question 4 of 5

In a simulation of rolling two dice 5,000 times, 832 rolls had a sum of 7. Which is closest to the theoretical probability of rolling a sum of 7?

Question 5 of 5

Which statement best explains why simulation is used instead of theoretical probability?