chapter 11 randomness. randomness random outcomes –tossing coins –rolling dice –spinning...

26
Chapter 11 Randomness

Upload: millicent-washington

Post on 28-Dec-2015

226 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Chapter 11 Randomness

Page 2: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Randomness

• Random outcomes– Tossing coins– Rolling dice– Spinning spinners

• They must be fair

Page 3: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Randomness

• Random outcomes– Tossing coins– Rolling dice– Spinning spinners

• They must be fair– Nobody can guess the

outcome before it happens

Page 4: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Randomness

• Random outcomes– Tossing coins– Rolling dice– Spinning spinners

• They must be fair– Nobody can guess the

outcome before it happens– Usually some underlying

set of outcomes will be equally likely

Page 5: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

1 2 3 4

Page 6: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Result

Number Percentage

1 About 5%

2 or 4 About 20%

3 About 75%

Page 7: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Result

Number Percentage

1 About 5%

2 or 4 About 20%

3 About 75%

It is not easy to be random!

Page 8: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

It’s Not Easy Being Random

• Computers have become a popular way to generate random numbers. – Even though they often do much better than

humans, computers can’t generate truly random numbers either.

– Since computers follow programs, the “random” numbers we get from computers are really pseudorandom.

– Fortunately, pseudorandom values are good enough for most purposes.

Page 9: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Example

• A cereal manufacturer puts pictures of famous athletes on cards in boxes of cereal in the hope of boosting sales– 20% of the boxes contain a picture of Tiger

woods– 30% for Lance Armstrong– 50% for Serena Williams

• Get a lottery ticket when all three pictures are collected

Page 10: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair
Page 11: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

How many boxes do we need to buy?

• If you are lucky,

• If you are very unlucky,

Page 12: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

How many boxes do we need to buy?

• If you are lucky, three boxes

• If you are very unlucky, infinitely many

Page 13: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

How many boxes do we need to buy?

• If you are lucky, three boxes• If you are very unlucky, infinitely many• But on average, how many?

– Go ahead and buy, then count (too costly)– A cheaper solution

• Use a random model• Assume that pictures are randomly placed in the

boxes• Assume that the boxes are randomly distributed to

stores

Page 14: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Practical Randomness

• We need an imitation of a real process so we can manipulate and control it.

• In short, we are going to simulate reality.

Page 15: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Then what?

• Use the model to generate random values– Simulate the outcomes to see what happens

• We call each time we obtain a simulated answer to our question a trial

• How do we generate the outcomes at random?

Page 16: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Random numbers

• How to generate random numbers?– Computer software

• Pseudorandom numbers– Computers follow programs!– The sequence of pseudorandom numbers eventually

repeat itself– But virtually indistinguishable from truly random numbers

– Books of random numbers• Not an interesting book, perhaps

Page 17: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair
Page 18: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

How do we get random integers in TI-83?

• MATH PRB• 5:randInt(• randInt(left,right, #)

– This allows repetition of the same integer– randInt (0,9,100) produces 100 random digits– randInt (0,57,3) produces three random integers betw

een 0 and 57• Remark: The textbook’s comments are wrong. Using this fun

ction, you can possibly get (14, 41, 14), which is not suitable for the dorm room example.

Page 19: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Back to cereal boxes

• How to model the outcome?– 20%, Woods (0,1)– 30% Armstrong (2,3,4)– 50% Williams (5,6,7,8,9)– 0 to 9 are equally likely to occur

• How to simulate the trial?– Open cereal boxes till we have one of each picture– Opening one box is the basic building block, called a

component of our simulation.– For example, ‘29240’ corresponds to the following

outcomes:

Page 20: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Back to cereal boxes

• How to model the outcome?– 20%, Woods (0,1)– 30% Armstrong (2,3,4)– 50% Williams (5,6,7,8,9)– 0 to 9 are equally likely to occur

• How to simulate the trial?– Open cereal boxes till we have one of each picture– Opening one box is the basic building block, called a

component of our simulation.– For example, ‘29240’ corresponds to the following

outcomes: Armstrong, Williams, Armstrong, Armstrong, Woods

Page 21: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Cereal (continue)

• Response variable– What we are interested in

• How many boxes it takes to get all three pictures• Length of the trial• ‘29240’ corresponds to 5 boxes

• Run more trials– 89064: 5 boxes– 2730: 4 boxes– 8645681: 7 boxes– 41219: 5 boxes– 822665388587328580: 18 boxes

• How many boxes do we expect to buy?– Take an average– Based on the first 5 trials: the average is 7.8 boxes– To get an objective estimate: run infinitely many trials

Page 22: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Cautions

• Simulation is different from the reality because– Model may not be 100% precise– Only limited number of trials

• Run enough trials before you draw conclusions

Page 23: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Simulation Steps

1. Identify the component to be repeated.2. Explain how you will model the component’s

outcome.3. State clearly what the response variable is. 4. Explain how you will combine the components

into a trial to model the response variable.5. Run many trials.6. Collect and summarize the results of all the

trials.7. State your conclusion.

Page 24: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Lottery for a dorm room

• 57 students participated in a lottery for a particularly desirable dorm room– A triple with a fireplace and private bath in the

tower– 20 participants were members of the same

varsity team– When all three winners were members of the

team, the other students cried foul

Page 25: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

Is it really a foul?• Whether an all-team outcome could reasonably be

expected to happen if every one is equally likely to be selected?

• Simulation– Component: selection of a student– 00-56: one number for one student

• 00-19: 20 varsity applicants• 20-56: the other 37 applicants

– Trial: randomly select three numbers from 00-56• Note we can’t put the same person in the room twice• If selecting the second person, the first selected person should be

excluded from the lottery– Response variable: ‘all varsity’ or not

• Draw conclusions by counting how often ‘all varsity’ occurs– The textbook gives 10% (only 10 trials)– If doing infinitely many trials, it should be 3.896104%

Page 26: Chapter 11 Randomness. Randomness Random outcomes –Tossing coins –Rolling dice –Spinning spinners They must be fair

What Can Go Wrong?

• Don’t overstate your case.– Beware of confusing what really happens with

what a simulation suggests might happen.

• Model outcome chances accurately.– A common mistake in constructing a

simulation is to adopt a strategy that may appear to produce the right kind of results.

• Run enough trials.– Simulation is cheap and fairly easy to do.