Simulating
Expected Value
Learn how to use random simulations to approximate \( E(X) \) and probability when exact computation is too complex.
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?
Where Simulation Shines
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
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
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.
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?
Assigning Random Numbers
When probabilities are not equally likely, map ranges of random numbers to outcomes proportionally.
How Many Trials Are Enough?
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
Common Mistakes
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?