Educerie · AP · Statistics
AP Statistics 2.3
Estimating Probabilities Using Simulation
How do we describe chance and variation, so that a claim about a population can be backed by numbers?
What you will learn
- Understand a random process, an outcome and an event, and that a trial is one whole run of the process
- Know the steps of a simulation: assign digits, define one trial, record the result, repeat, estimate
- Understand that the probability of an event is its long-run relative frequency
- Know what the law of large numbers says and what it does not say
You must be able to
- Describe how to assign random digits so each outcome has the right share
- Define one trial of a simulation and say what is recorded from it
- Estimate a probability as the number of trials with the event over the number of trials
- Read a tally of simulation results to estimate an at least or exactly probability
- State the law of large numbers and reject the idea that results even out
- Explain why more trials give a better estimate
In the exam. Section I multiple choice asks which setup correctly simulates a described situation, how to read a simulation's results as an estimate, and what the law of large numbers does and does not say. In Section II, simulation is the first step in Unit 2 questions: describe how you would simulate, then use the results. The same idea comes back for binomial probabilities (2.10), for sampling distributions (2.12) and for the randomization tests of later units. Skill 3.C.
1Words that must be exact
Take the process "a basketball player takes 4 shots".
- Random process: taking the 4 shots, because the result depends on chance.
- Outcome: the result of one trial, for example "make, miss, make, make".
- Event: a collection of outcomes. "At least 3 of the 4 shots go in" is an event that contains several outcomes.
- Trial: one full run of the random process. In a simulation, one trial means all 4 simulated shots, not one shot.
Mixing up the trial and the single step inside it is the most common way to lose marks here.
2Designing a simulation
Example (invented): a player makes 70% of her shots, and each shot is independent of the others. We want the probability that she makes at least 3 of 4 shots. A theoretical answer exists, but the exam asks you to describe how a simulation would find it.
Step 1. Assign digits to the outcomes of one step. Random digits 0 to 9 are equally likely. Seven of the ten digits is 70%, so let the digits 0, 1, 2, 3, 4, 5, 6 stand for "make" and 7, 8, 9 stand for "miss". Every outcome of one shot gets a share of the digits equal to its probability.
Step 2. Define one trial. Use 4 random digits, one for each shot. Count how many are in 0 to 6.
Step 3. Record the result of the trial. Write down the count, or just whether the event "at least 3 makes" happened.
Step 4. Repeat many times. Table 1 shows 10 trials, each of 4 digits, with the number of makes.
| Trial | Digits | Makes | At least 3? |
|---|---|---|---|
| 1 | 7 9 5 4 | 2 | no |
| 2 | 2 2 0 5 | 4 | yes |
| 3 | 8 7 9 1 | 1 | no |
| 4 | 5 8 9 0 | 2 | no |
| 5 | 6 2 7 6 | 3 | yes |
| 6 | 2 2 3 0 | 4 | yes |
| 7 | 1 2 8 9 | 2 | no |
| 8 | 1 6 1 4 | 4 | yes |
| 9 | 3 3 6 1 | 4 | yes |
| 10 | 4 3 6 4 | 4 | yes |
Step 5. Estimate. The event happened in 6 of the 10 trials:
Ten trials is very few. A computer repeating the same 4-digit trials 10 000 times gave about 0.65, and the exact value for this setting is 0.652. The ten-trial estimate was within chance variation of that, and a different ten trials would have given a different estimate.
That is the form of an AP answer: say what each digit means, say what one trial is, say what you count, say how many times you repeat, and say that the answer is the proportion of trials in which the event occurs.
3A process with no fixed number of steps
Example (invented): a cereal company puts one of 4 toy types, equally likely, in each box. How many boxes must you buy to get all 4 types?
- Digits: 1, 2, 3 and 4 stand for the four toys. Ignore 0 and 5 to 9 (skip them and take the next digit).
- One trial: keep reading digits, counting boxes, until all of 1, 2, 3 and 4 have appeared. The number of boxes is the outcome of the trial.
- Repeat: 10 trials gave 5, 4, 13, 8, 5, 11, 10, 6, 11 and 8 boxes.
Four of the 10 trials needed more than 8 boxes, so the estimate of "more than 8 boxes" is 0.4. A much longer simulation of 20 000 trials gave 0.38, and the average number of boxes was about 8.3.
A good simulation can answer a question for which a formula is hard. The same steps apply whether the number of steps in a trial is fixed or not.
4Long-run relative frequency and the law of large numbers
The probability of an event is its relative frequency over a large number of trials. An empirical (data-based) relative frequency from many trials is an estimate of the true probability.
The law of large numbers says that, for independent trials, as the number of trials increases the relative frequency of the event gets closer and closer to a single value, the probability.
Figure 1 shows 500 trials of the shooting simulation, with the relative frequency of "at least 3 of 4" worked out after each trial.
- After 10 trials the proportion was 0.5. After 50 it was 0.64, after 100 it was 0.62 and after 500 it was 0.654.
- At first the line swings widely. By 500 trials it hardly moves, and it sits close to the dashed line at the true probability, 0.652.
The law has limits. It does not say any of the following.
- That the counts even out. The number of makes does not have to catch up with the expected number. The proportion settles because the early chance variation is swamped by more and more later trials.
- That a streak will be balanced. A fair coin that gave 8 heads in 10 flips is not "due" tails. The next flip is still 50% heads, since trials are independent.
- That a small number of trials is close. Ten trials are not close to the probability, and Figure 1 shows how far off they can be.
5Reading the results of a simulation
Example: a simulation of 200 trials counts the number of defective items in a batch of 5, and gives this tally.
| Defective items | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| Number of trials | 70 | 80 | 40 | 10 | 0 | 0 |
The tally adds to 200 trials. The estimated probability of at least 2 defective items counts every trial with 2 or more:
The estimate for exactly 2 is , and for at least 1 is . Read the wording carefully ("at least", "more than", "exactly") before choosing which rows to add.
More trials give a better estimate. One simulation will not give exactly the true probability, and two simulations of the same size will usually give two different estimates.
Practice questions
30 questions on this note, from easy to hard. Each one you get right lights a star of this topic's constellation.