### Simulation

```Simulation
AP STATISTICS
“Statistics means never having to say you're certain.”
Introduction
 Toss a coin three times. What is the likelihood of a
run of three or more consecutive heads or tails?
 A couple plans to have children until they have a girl
or until they have four children, whichever comes
first. What are the chances that they will have a girl
among their children?
Three methods we can use to answer questions
about chance
 Try to estimate the likelihood of a result of interest
by actually observing the random phenomenon
many times and calculating the relative frequency of
the results.
 Develop a probability model and use it to calculate a
theoretical answer.
 Start with a model that, in some fashion, reflects the
truth about the random phenomenon, and then
develop a plan for imitating (or simulating) a
number of repetitions of the procedure.
Simulating the birth of children
A couple plans to have children until they have a girl or until
they have four children, whichever comes first. What are
the chances that they will have a girl among their children?
 Let a flip of a fair coin represent a birth, with heads
corresponding to a girl and tails a boy. Assuming that girls
and boys are equally likely to occur on any birth, the coin
flip is an accurate imitation of the situation.
 If this coin flipping procedure is repeated many times, to
represent the births in a large number of families, then the
proportion of times that a head appears within the first four
flips should be a good estimate of the true likelihood of the
couple’s having a girl.
Simulating the birth of children
 A single die could also be used to simulate the birth
of a son or daughter. Let an even number represent
a girl, and let an odd number represent a boy.
 Simulation
The imitation of chance behavior, based
on a model that accurately reflects the
situation, is called a simulation.
Performing a Simulation
State: What is the question of interest about some chance process?
Plan: Describe how to use a chance device to imitate one repetition of the
process. Explain clearly how to identify the outcomes of the chance
process and what variable to measure.
Do: Perform many repetitions of the simulation.
Conclude: Use the results of your simulation to answer the question of
interest.
We can use physical devices, random numbers (e.g.
Table D), and technology to perform simulations.
Simulation Steps
1. State the problem (model) or describe the random
phenomenon and define the key components.
 Toss a coin 10 times. What is the likelihood of a
run of at least 3 consecutive heads or 3 consecutive
tails?
(Optional on AP Exam) There are two:
 A head or tail is equally likely to occur on each toss.
 Tosses are independent of each other (that is, what
happens on one toss will not influence the next
toss.)
Simulation Steps
2. Plan: Assign digits to represent outcomes. (State what
you would record.)
 One digit simulates one toss of the coin.
 Odd digits represent heads; even digits represent tails.
 Successive digits in the table simulate independent
tosses.
3. Do: Simulate many repetitions. (Conduct the trials.
The AP Exam requires that you use a random number
table.)
 Looking at 10 consecutive digits in a random number
table simulates one repetition. Be sure to keep track of
whether or not the event we want (a run of at least 3
heads or at least 3 tails) occurs on each repetition.
Random Digit Table
Digits: 19223 95034 05756 28713 96409 12531
H/T? HHTTH HHTHT THHHT TTHHH HTTTH HTHHH
Runs of 3?
 Suppose that 22 additional repetitions were done for a total of 25
repetitions. 23 of them did have a run of 3 or more heads/tails.
Simulation Steps
5. State your conclusions. (Usually only
appropriate if you have at least 100 trials.)
 We estimate the probability of a run of size three by
the proportion:
23
estimated _ probabilit y 
 0.92
25
Assigning digits
Example: Choose a person at random
from a group of which 70% are
employed.
 One digit simulates one person:
0, 1, 2, 3, 4, 5, 6 = employed
7, 8, 9 = not employed
Assigning Digits
Example: Choose one person at random from a
group of which 73% are employed.
 Now we must let two digits simulate one person:
00, 01, 02, …, 72 = employed
73, 74, 75, …, 99 = not employed
ALSO ACCEPTABLE:
01, 02, 03, …, 73 = employed
74, 75, 76, …, 00 = not employed
Assigning Digits
EXAMPLE: Choose one person at random from a group of which 50%
are employed, 20% are unemployed, and 30% are not in the labor
force.
There are now three possible outcomes. One digit simulates one
person:
0, 1, 2, 3, 4 = employed
5, 6 = unemployed
7, 8, 9 = not in the labor force
ALSO ACCEPTABLE:
0, 1 = unemployed
2, 3, 4 = not in the labor force
5, 6, 7, 8, 9 = employed
Frozen Yogurt Sales
Orders of frozen yogurt (based on sales) have
the following relative frequencies: 38%
chocolate, 42% vanilla, and 20% strawberry.
We want to simulate customers entering the
store and ordering yogurt.
(Follow the 5 step process.)
STEP 1: How would you simulate 10 frozen yogurt
sales based on this recent history?
Step 2: State the Assumptions
 Orders of frozen yogurt (based on sales) have the
following relative frequencies: 38% chocolate, 42%
vanilla, and 20% strawberry. We also assume that
customers order one flavor only, and that the
customer’s choices of flavors do not influence one
another.
Step 3: Assign Digits to Represent Outcomes
 We will do pairs of digits. Why?
00 to 37 = outcome chocolate (C)
38 to 79 = outcome vanilla (V)
80 to 99 = outcome strawberry (S)
Step 4: Simulate Many Repetitions
 Suppose that we have the following sequence of
random numbers:
19352 73089 84898 45785
This yields the following 2-digit numbers:
19 35 27 30 89 84 89 84 57 85
which correspond to the outcomes:
C
C
C C S
S S
S
V
S
Step 5: State your conclusions
The problem only asked for the process, but let’s look
at the results:
 We estimate that the probability of an order for
chocolate to be 4/10=0.4, vanilla to be 1/10 = 0.1,
and strawberry to be 5/10 = 0.5.
 However, 10 repetitions are not enough to be
confident that our estimates are accurate.
```