simulations - uh

31
Simulations Section 6.3 Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c Department of Mathematics University of Houston Lecture 17 - 2311 Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston ) Section 6.3 Lecture 17 - 2311 1 / 17

Upload: others

Post on 06-Apr-2022

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Simulations - UH

SimulationsSection 6.3

Cathy Poliak, [email protected] in Fleming 11c

Department of MathematicsUniversity of Houston

Lecture 17 - 2311

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 1 / 17

Page 2: Simulations - UH

Popper Set Up

Fill in all of the proper bubbles.

Make sure your ID number is correct.

Make sure the filled in circles are very dark.

This is popper number 13.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 2 / 17

Page 3: Simulations - UH

Popper #13 Questions

Before a new variety of frozen muffins is put on the market, its issubjected to extensive taste testing. People are asked to taste the newmuffin and a competing brand and to say which they prefer (bothmuffins are unidentified in the test).

1. What type of study is this?a) An observational study.b) An experiment.c) A stratified sample.d) A census.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 3 / 17

Page 4: Simulations - UH

Popper #13 Questions

You are going to test two new varieties of fish food versus a commonlyused fish food. You set up an experiment as follows: 60 fish arerandomly assigned to each of three different tanks. One tank israndomly selected to receive one of the new foods and another toreceive the other new food. The remaining tank will receive thecommonly used food. Fish growth is measured over time.

2. This is an example of:a) a randomized block design.b) a completely randomized design with no control group.c) a completely randomized designed with a control group.d) a double-blind matched pairs design.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 4 / 17

Page 5: Simulations - UH

Popper #13 Questions

3. Suppose you are interested in the effects on boys of differentdosages of a new drug to treat ADHD. You set up an experimentto consider the factor of dosage with two levels (300 mg vs. 500mg). Which would be the best choice for the different treatmentgroups of the experiment within each block?a) Three groups: no drug, 300 mg of new drug, 500 mg of new drug.b) Two groups: placebo drug and either 300 mg of new drug or 500 mg

of new drug.c) Four groups: no drug, placebo drug, 300 mg of new drug, 500 mg of

new drug.d) Three groups: placebo drug, 300 mg of new drug, 500 mg of new

drug.e) Two groups: 300 mg of new drug and 500 mg of new drug.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 5 / 17

Page 6: Simulations - UH

Simulating Experiments

Simulation is the imitation of a chance behavior based on amodel that reflects an experiment.

We can use computer software such as R or the table of randomdigits to simulate experiments.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 6 / 17

Page 7: Simulations - UH

Example

Mudlark Airlines has a 15-seater commuter turboprop that is used forshort flights. Their data suggest that on average about 8% of thecustomers who buy tickets are no-shows. Wanting to avoid emptyseats, they decide to sell 17 tickets for each flight. Ticketed customerswho cannot be seated on the plane will be accommodated on anotherflight and will receive a certificate good for a free flight at another time.You have been retained as a consultant to Mudlark. Your job is todetermine if this particular overbooking is sound strategy. Usesimulation methods to perform your analysis. Explain your solutioncompletely, and write your recommendation to the company onwhether this policy is good for the company or whether is should beadjusted.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 7 / 17

Page 8: Simulations - UH

Our Simulation using R

We use sample(1:100,15).

Since 8% are no-shows we will represent any values 1 - 8 be theno-shows and 9 - 100 represent the ones that show up.

We use 15 because the airplane is a 15-seater.

From R I get: 33 47 13 69 77 38 21 42 1 26 4 57 19 55 9

So there were two passengers that did not show up.

To get a better understanding we need to replicate this simulation.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 8 / 17

Page 9: Simulations - UH

From the first simulation I got 2 passenger that are no-shows. Irepeated this again in R 9 more times and the following are results.

The result of the simulation Number of no-shows69 72 17 52 26 58 5 94 73 16 38 56 13 37 78 146 11 76 57 39 82 33 18 49 54 99 94 81 16 72 081 16 98 30 66 36 95 77 34 85 88 13 50 24 93 080 6 37 3 25 89 75 49 67 35 46 92 77 27 31 252 11 53 63 13 97 8 88 45 25 94 40 61 3 58 219 85 48 26 53 58 96 24 76 13 41 18 57 45 56 075 55 63 84 18 27 41 38 9 26 17 53 61 42 4 125 41 95 26 22 40 51 47 61 79 20 23 88 37 3 11 10 39 68 100 60 63 20 12 83 53 94 74 48 46 1

From our 10 simulations what is the mean amount of no-shows?

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 9 / 17

Page 10: Simulations - UH

What is our recommendation?

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 10 / 17

Page 11: Simulations - UH

Second Example

Joey is interested in investigating streaks when flipping coins. Hewants to use simulation methods to determine the longest run ofheads, on average, for 20 consecutive coin flips.a. Describe a correspondence between random digits from a random

digit table and outcomes.I We know that getting heads up occurs 50% of the time. If we use

two-digits and let so that it is 00 - 99 then let the 100% would be 00.Anything between 01 - 50 represent heads up and anything between51 - 99 and 00 is tails up. However, this can be tedious. We can alsouse one digit and let anything between 1 and 5 inclusive representheads up, otherwise it will be tails up. Outcomes: count the repetitionof heads until a tail is up.

b. What will constitute one repetition in this simulation?I For 20 consecutive coin flips we have to look at 20 digits.

c. Staring with line 101 in the random digit table, carry out 10repetitions and record the longest run of heads for each repetition.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 11 / 17

Page 12: Simulations - UH
Page 13: Simulations - UH

Simulation using the Random Digit Table

Starting at line 101 the following is 10 simulations:

Simulation from table Longest run of heads9 8 3 6 0 2 6 5 3 4 4 7 3 8 4 9 4 6 1 2 48 8 6 6 6 1 4 1 7 0 1 0 8 4 7 0 5 5 6 7 35 5 5 5 6 5 9 8 6 3 8 6 6 0 7 0 0 0 9 4 47 7 2 1 3 3 5 7 1 1 5 2 8 5 1 4 2 1 0 8 53 1 6 3 4 1 5 3 9 9 7 3 4 7 6 7 7 4 1 2 50 6 1 8 6 1 6 6 3 6 5 4 3 0 7 1 4 9 4 7 31 3 7 8 5 1 1 5 0 9 5 4 8 9 1 9 8 3 7 5 46 8 3 7 7 5 0 5 7 2 0 8 4 5 3 8 0 3 7 6 38 0 3 7 6 7 3 8 4 2 9 5 4 6 5 5 9 7 4 6 23 8 0 7 8 2 5 7 2 7 7 8 5 0 2 9 5 3 2 4 4

What is the mean run length for the 10 repetitions?

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 12 / 17

Page 14: Simulations - UH

Similar to Problem #4 from section 6.3

A game is played by two people each rolling a single number cube.The player with the higher value on their cube will win. If the playersboth roll the same value, they must both roll again.a. What constitutes a single play of this game?

b. Describe a correspondence between the random digits from arandom digit table and outcomes in the game.

c. Use the random digit table, beginning on line 125 to simulate 10games. Report the proportion of times player 1 wins the game.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 13 / 17

Page 15: Simulations - UH

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 14 / 17

Page 16: Simulations - UH

Popper #13 Questions

4. A game of chance is based on rolling a die two times insuccession (A six-sided die with numbers 1 - 6). The player wins ifthe larger of the two numbers is greater than 3. Which of thefollowing situations would simulate 9 plays of this game (9repetitions)?a) Choosing 9 digits from the random number table (discarding 0, 7, 8,

and 9)b) Choosing two digits from the table (discarding 0, 7, 8, and 9) nine

times.c) Choosing 54 digits from the random number table (discarding 0, 7, 8,

and 9).d) Choosing two single digits from the random number table (discarding

0, 7, 8, and 9).

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 15 / 17

Page 17: Simulations - UH

Similar #34 On Test Review

A game is played with a spinner. If your spin lands on A, you win $1. Ifyour spin lands on B, you lose $1. If the spinner lands on C, nothinghappens. Ten people are playing the game. P(A) = 0.2, P(B) = 0.5 andP(C) = 0.3.a. Using single digits from the random digit table, describe how you

will run a simulation for the 10 players.

b. Using line 120 from the random digit table, carry out the simulation3 times.

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 16 / 17

Page 18: Simulations - UH

c. Based on your simulation, how many people won $1 for each run?How many lost $1?

Cathy Poliak, Ph.D. [email protected] Office in Fleming 11c (Department of Mathematics University of Houston )Section 6.3 Lecture 17 - 2311 17 / 17

Page 19: Simulations - UH

Exam 2 ReviewReview

Cathy Poliak, [email protected]

Department of MathematicsUniversity of Houston

Exam 2 Review

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 1 / 20

Page 20: Simulations - UH

Outline

1 Material Covered

2 What is on the exam

3 Examples

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 2 / 20

Page 21: Simulations - UH

What to Expect on the Exam

The test has two parts1. 40% of the grade is based on multiple choice questions. Five

questions.

2. 60% of the grade is based on free response questions. Three freeresponse questions with multiple parts.

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 3 / 20

Page 22: Simulations - UH

Chapter 4

Section 1 - Density curves and the Uniform distribution

Section 2 - Normal distribution: Empirical rule and using R (pnormand qnorm)

Section 3 - Standard Normal Calculations: z-scores and using thez-table

z − value - meansd

Section 4 - Sampling distributions of x̄ and p̂.

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 4 / 20

Page 23: Simulations - UH

Sampling Distributions

The distribution of the sample mean, x̄ .I Center: Expected value of x̄ = µ the population mean of the original

distribution.I Spread: Standard error of x̄= σ/

√n the population standard

deviation divided by the square root of the sample size.I Shape: Normal if the original distribution is Normal or the sample

size is larger than 30, Central Limit Theorem.

The distribution of the sample proportion, p̂.I Center: Expected value of p̂ = p the population proportion.I Spread: Standard error of p̂ =

√p(1−p)

n .I Shape: Normal if np > 10 and n(1− p) > 10.

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 5 / 20

Page 24: Simulations - UH

Chapter 5: Bivariate Data

Section 1: Scatterplots

Section 2: Correlation in R cor(x,y)

Section 3: Least Squares Regression Line (LSRL) in R lm(y∼x)

Section 4: Residuals in R resid(lm(y∼x)). To plot a residual plotplot(x,resid(lm(y∼x))).

residual = observed y − predicted y

Section 5: Non-linear Models, transformations.

Section 6: Relations in categorical data.I Using a two-way table. Finding percents.I Determining marginal distributions.I Determining conditional distributions.

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 6 / 20

Page 25: Simulations - UH

Chapter 6: Sampling and Experiments

Section 1: Types of sampling designs

Section 2: Types of experiments

Section 3: Simulating experiments

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 7 / 20

Page 26: Simulations - UH

Possible Free Response Questions

Find probabilities for a Normal distribution. Be able to sketch thedistribution and shade the approprate area in the Normal curve.Find z-scores. Find the value of X corresponding to a particularprobability.

Draw a scatterplot, find the LSRL, interpret the slope, find thecorrelation coefficient, coefficient of determination (and interpretthese values), find a residual value, show the residual plot anddetermine if the model is a good fit or not based on allobservations of values found.

Given a section from the random digit table be able to simulate anexperiment, see problem #7 from section 6.3.

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 8 / 20

Page 27: Simulations - UH

What You Need an What is Provided

ProvidedI Basic calculator; it will be a link you see in the exam.I R; it will be a link you see in the exam.I z-table; it will be a link you see in the exam.

Can bringI Calculator; if it is memory based CASA will remove the memory.I Pencil; you will need something to write with for the free response

questions.I Your Cougar Card.

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 9 / 20

Page 28: Simulations - UH

Uniform Distribution

1. Consider a uniform density curve defined from x = 0 to x = 8.What percent of observations fall below 5?a) 0.20b) 0.75c) 0.63d) 0.50e) 0.13

2. Consider a uniform density curve defined from x = 0 to x = 9.What percent of observations fall between 1 and 6?a) 0.17b) 0.68c) 0.56d) 0.67e) 0.11

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 10 / 20

Page 29: Simulations - UH

Normal Distribution

1. If X is normally distributed with a mean of 10 and a standarddeviation of 2, find P(10 ≤ X ≤ 13.4).a) 0.755b) 0.855c) 0.455d) 0.655e) 0.555

2. Find a value of c so that P(Z ≤ c) = 0.47.a) 1.08b) 0.42c) -0.08d) 0.08e) 0.92

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 11 / 20

Page 30: Simulations - UH

Standard Normal Distribution

Find the following and sketch the curve.1. Find P(Z<1.2)2. Find P(Z > -1.39)3. Find c such that P(Z < c) = 0.8454. Find c such that P(Z > c) = 0.845

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 12 / 20

Page 31: Simulations - UH

Sampling Distributions

Suppose a random sample of 70 measurements is selected from apopulation with a mean of 35 and a variance of 300. Select the pairthat is the mean and standard error of x̄ .a) [35,2.571]

b) [35,2.371]

c) [35,2.071]

d) [70,2.571]

e) [35,2.271]

Cathy Poliak, Ph.D. [email protected] (Department of Mathematics University of Houston )Review Exam 2 Review 13 / 20