01 / 20

Simulating
Expected Value

Learn how to use random simulations to approximate \( E(X) \) and probability when exact computation is too complex.

Math 3

What Is Expected Value?

The expected value \( E(X) \) of a random variable \( X \) is the long-run average outcome you would observe if you repeated an experiment infinitely many times. It is the weighted average of all possible outcomes.

When the number of outcomes is small, we can compute \( E(X) \) exactly. But what happens when the situation is too complex for a neat formula?

Why Use Simulation?

✕ Exact Calculation
Requires knowing every outcome and its probability: often impossible for complex, multi-step scenarios.
✓ Simulation
Run the experiment many times with a random number generator and take the average: works for any scenario.

Where Simulation Shines

★ Games of Chance
Card games, dice with special rules, lotteries with conditional payouts.
★ Biology
Modeling gene inheritance or population survival across many generations.
★ Finance
Estimating expected portfolio returns under uncertain market conditions.

In each case, the outcome space is enormous or the probabilities are hard to compute analytically: simulation lets us estimate the answer anyway.

The Law of Large Numbers

\(E(X)\)
Number of trials (\(n\))
Sample mean 10 100 1,000 10,000

The green curve shows \( \bar{X}_n \) settling toward the true \( E(X) \) as the number of trials grows. Early trials are noisy; with enough repetitions, the estimate stabilizes.

Simulation vs Exact Calculation

Simulation Exact Calculation
When to use Complex or unknown probability model Simple, well-defined outcome space
Accuracy Approximate: improves with more trials Exact: gives the true value
Formula needed? No: just a procedure to generate outcomes Yes: \( E(X)=\sum x_i p_i \)
Speed Needs many trials (computer helps) Instant if formula is known
Example Expected turns to finish a board game Expected value of rolling one die

How to Run a Simulation

1
Define the experiment. Identify the random process and what outcome \( X \) you are measuring.
2
Choose a random device. Use a random number generator, dice, spinner, or random number table.
3
Assign outcomes to numbers. Map each random number range to a real-world outcome with the correct probability.
4
Run many trials. Repeat the experiment a large number of times (at least \( n \geq 100 \); more is better).
5
Compute the sample mean. Calculate \( \bar{X}_n = \frac{1}{n}\sum X_i \). This approximates \( E(X) \).

Example 1: Fair Die

Roll a fair six-sided die. The exact expected value is \( E(X) = \frac{1+2+3+4+5+6}{6} = 3.5 \). Let's verify with a simulation of 20 rolls.

1 2 3 4 5 6
\(3.5\)
Trial number Value / Mean Running mean
True \(E(X)\)

Example 2: Sum of Two Dice

A carnival game costs \$5 to play. You roll two dice. If the sum is \( \geq 10 \), you win \$20. Otherwise, you win nothing. What is the expected profit?

Example 3: Coupon Collector

A cereal brand has 5 different toys. Each box contains one toy chosen uniformly at random. How many boxes must you buy, on average, to collect all 5 toys?

1
Simulate one collection: Randomly pick a number 1 to 5 repeatedly until all 5 have appeared. Record the count.
2
Repeat 10,000 times and compute \( \bar{X}_{10000} \).
3
Result: \( \bar{X}_{10000} \approx 11.4 \), matching the exact value beautifully.

Assigning Random Numbers

When probabilities are not equally likely, map ranges of random numbers to outcomes proportionally.

Win nothing 00 to 49 (50%) Win $10 50 to 79 (30%) Win $50 80 to 99 (20%) 00 50 80 99 Random number table: 00 to 99

How Many Trials Are Enough?

\(E(X)\)
\(n=10\)
\(n=100\)
\(n=1,000\)
\(n=10\text{k}\)
Estimate range

Simulating Probability

Simulation also approximates probabilities. The estimated probability of event \( A \) after \( n \) trials is:

This is just a special case of expected value where \( X = 1 \) if \( A \) occurs and \( X = 0 \) otherwise, so \( E(X) = P(A) \).

Designing a Simulation Model

1. Identify the variable
What quantity \( X \) are you measuring? Profit? Count? Time?
2. Model randomness
What is random? Use digits 0 to 9, or a calculator's RNG, to mirror the probabilities.
3. Define one trial
Precisely describe the steps that produce a single value of \( X \).

Common Mistakes

✕ Too few trials
Running only 10 to 20 trials and trusting the result. The Law of Large Numbers requires many repetitions (hundreds or thousands).
✕ Wrong probability mapping
Assigning random number ranges that don't match the true probabilities. For example, using 1 to 3 for a 25% event instead of 1 to 25 out of 100.
✕ Confusing one trial with one number
Some experiments need multiple random numbers per trial. Rolling two dice needs two random selections per trial, not one.

Question 1 of 5

A student simulates rolling a fair die 500 times and computes the sample mean. According to the Law of Large Numbers, this sample mean should be close to:

Question 2 of 5

A game has a 40% chance of winning \$10 and a 60% chance of losing \$5. To simulate this using two-digit random numbers (00 to 99), which mapping is correct?

Question 3 of 5

In a simulation of 200 trials, an event occurred 56 times. What is the estimated probability of this event?

Question 4 of 5

A student runs a simulation with \( n = 50 \) trials and gets an estimate of \( E(X) \approx 7.2 \). She wants to halve the standard error of her estimate. How many total trials does she need?

Question 5 of 5

Which scenario is best suited for simulation rather than exact calculation?