random numbers
Download
Report
Transcript random numbers
Chapter 9
Understanding
Randomness
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
1
Objectives:
Explain what it means to be random.
Accurately model a situation through simulation.
34. Discuss the results of a simulation study and draw
conclusions about the questions being investigated.
32.
33.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
Slide 1- 2
2
9.1
What is
Randomness?
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
3
Random Procedures
A random procedure is a procedure whose outcome
cannot be known in advance
How can we determine the probability a random
procedure will have a certain outcome?
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
4
Approach #1: Relative Frequency
Approximation of Probability
Conduct/observe a procedure n times, and count the # of
times that an outcome of interest occurs. Based on
these results, the probability of the outcome is
estimated as follows:
# of times outcome occurred
P(outcome)
# of times the procedure was repeated
This approach obtains an approximation (estimate)
instead of an exact value
Law of Large #’s: As the # of trials increases, the
relative frequency probability approaches the actual
probability
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
5
Approach #2:
Classical Approach to Probability
Assume that a given procedure has n different outcomes
and that each of these outcomes has an equal chance
of occurring. If an outcome of interest can occur in s of
these n ways, then
# of ways outcome can occur
s
P(outcome)
# of different possible outcomes n
This approach requires equally likely outcomes
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
6
Approach #3:
Subjective Probabilities
P(outcome) is estimated by using personal judgment
about the likelihood of an event
This approach is needed when there is no repeatable
random experiment available
Examples:
• What is the probability it will rain tomorrow?
• What is the probability the stock market will rise
tomorrow?
• What is the probability more than 5 students in this class
will get an “A” on the next exam?
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
7
Simulation
There are many situations when we want to estimate the
probability of an outcome of a random procedure, but:
•The
classical approach to probability is not possible,
and/or
•The
relative frequency approach is
unwieldy/expensive/infeasible/etc.
In these situations we can simulate the random
procedure in order to estimate the probability of our
outcome of interest
We need random numbers to simulate the randomness
in real life
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
8
Where do we get random numbers?
Random number tables from random sources in nature
• Your textbook has a random number table in Appendix
D
Computers and your calculator can generate
pseudorandom numbers.
• StatCrunch: Data → Simulate Data
• Use
MATH -> PRB -> randInt(low, high, numtrials) to
generate a set of random integers
• E.g. randInt(0,1,5) will generate a set of 5 random
digits of 0 or 1.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
Slide 1- 9
9
How to use random numbers
It depends on the context… if your outcome occurs with probability
1/5 then you could generate a set of random numbers on your
calculator from 1 to 5 and let 1 represent your outcome
occurring.
• RandInt(1,5,100) will generate 100 such digits
Or you could use a random number table (digits 0-9) and let 0 and
1 be your outcome occurring
• Or use RandInt(0,9,100) to generate 100 such digits
Or you could use a random number table and look at 2-digit
numbers and let 0-19 be your event occurring.
• Or use RandInt(0,99,100) to generate 100 such numbers
There are many ways to do this.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
Slide 1- 10
10
Choosing 10 Random Numbers from 1 to
4 with StatCrunch
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
11
9.2
Simulating by Hand
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
12
Picking Sports Cards
Cereal boxes contain one of three
athlete cards:
• 20% chance of Hope Solo
• 30% chance of Danica Patrick
• 50% chance of Blake Griffin
How many boxes would you expect to buy to get one of
each?
• It is too expensive to buy hundreds of boxes and
open them.
• Instead, use simulation.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
13
Steps for Simulation
Specify how to model a component outcome using
equally likely random digits:
1. Identify the component to be repeated.
• Opening a cereal box
2. Explain how you will model the experiment’s outcome.
• Assign outcomes to the equally likely random digits
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• 0 or 1 → Hope Solo
• 2, 3, or 4 → Danica Patrick
• 5, 6, 7, 8, or 9 → Blake Griffin
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
14
Steps for Simulation
Specify how to simulate trials:
3. Explain how you will combine the components to
model the trial.
• Look at each digit until all three types are found.
4. State clearly what the response variable is.
• We want to find the number of boxes it takes to get
all three pictures.
Put it all together to run the simulation:
5. Run several trials
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
15
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Using TI-83/84 RandInt(0,9,10)
… we may only need 3 picks, but 10
Will give us more than enough.
With StatCrunch:
• The first column rounded is
• 6, 5, 7, 3, 2, 1, 3, 8, 5, 0, 0, 2, …
• It took 6 picks to have at least
one of each type of card.
•
The second column rounded is
• 5, 1, 0, 4, 4, 7, 5, 8, 8, 4, 4, 3, 6, ….
• It took 4 picks to have at least one of each.
Continue this process until you have a large sample.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
16
Steps for Simulation
Analyze the response variable:
6. Collect and summarize the
results of the trials.
• As you have learned, look
for shape, center, spread,
outliers, etc.
Trial
Number
Number of
Boxes
1
6
2
4
3
7
4
5
The first four trials
organized in a table.
7. State your conclusion
• We estimate it takes a median of 5 boxes to
complete the collection, but it could take a
lot more.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
17
Simulating a Dice Game
Rules
• Roll a total higher than your opponent without going
over 21.
• If your opponent rolled an 18, how many rolls do you
expect to make and what is your chance of winning?
How will you simulate the components?
• A component is one roll of the die.
• Generate numbers from 1 to 6.
(RandInt(1,6,10))
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
18
Dice Game of 21
How will you combine the components? What is the
response variable?
•I will add up the numbers until I get a total greater than 18
and count the number of rolls.
•If the total ≤ 21, it is a win.
•If the total > 21, it is a loss.
Use StatCrunch and display a few outcomes:
•1, 3, 5, 1, 2, 3, 6, 5, 6, 3, …: 7 tosses. Total: 21 win
•2, 2, 4, 1, 5, 6, 1, 1, 4, 5, …: 6 tosses. Total: 20 win
•2, 3, 1, 2, 5, 2, 1, 6, 3, 1, …: 8 tosses. Total: 22 loss
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
19
Conclusions
Suppose you ran 30 trials
and tallied the results as
shown. What are your
conclusions?
• I typically roll about five or six times for each
game.
• I expect to win about 70% of the time.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
20
Lottery for the Dorms
57 students are in a lottery for the
spacious triple dorm room. 20 were
from the varsity team and all three
winners were from this team.
• How likely is this? Was it rigged?
Plan → Simulation
• Components: Selection of the students.
• Outcomes: Generate numbers from 1 to 57. 1-20
will represent the team members.
• Trial: Pick the first three distinct numbers.
• Response Variable: Yes if all three are 1-20
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
21
Show
Mechanics
• Use StatCrunch or RandInt to generate 100 sets of
three distinct random numbers between 1 and 57.
•
Some are: 5,24,45; 26,56,27; 47,11,51; 35,16,9;
33,15,13; 47,37,32; 21,43,6; 15,22,28; 24,13,42;
38,33,17; 26,36,52; 28,3,55; 25,51,38; 36,18,34;
9,40,52; 5,17,2; 24,49,20; 22,38,45; 38,54,56;
Analyze
• Only 3 out of the 100 trials resulted in “All Varsity.”
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
22
Conclusions
In the simulation, only 3 out of 100 were “All Varsity.”
While 3% is only a small chance, it is not impossible. It
looks pretty suspicious.
Is 3% a small enough chance to make a formal
accusation?
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
23
What Can Go Wrong?
Don’t Overstate Your Case
• Simulation is not reality, it only indicates probability.
Model Outcome Chances Accurately
• What would be wrong with generating random
numbers 0, 1, 2, 3 to indicate the number of team
members?
• There is not a 25% chance of each. They are not
equally likely.
Run Enough Trials
• Don’t just do a few trials. Err on the side of a large
number of trials.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
24
Example – Actually conduct this
simulation using all 7 steps
Many couples want to have both a boy and girl. If they
decide to continue to have children until they have one
child of each sex, what would the average family size
be?
Assume that boys are girls are equally likely.
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
Slide 1- 25
25
Example – Actually conduct this
simulation using all 7 steps
You are playing a children’s game in which the number
of spaces you will get to move is determined by the
rolling of a die. You must land exactly on the final
space in order to win. If you are 10 spaces away, how
many turns might it take you to win?
Copyright © 2014, 2012, 2009 Pearson Education, Inc.
Slide 1- 26
26