32nd International Conference on Technology in Collegiate Mathematics
ictcm.com | #ICTCM
VIRTUAL CONFERENCE
VIRTUAL CONFERENCE ictcm.com | #ICTCM ENHANCING A PROBABILITY - - PowerPoint PPT Presentation
32 nd International Conference on Technology in Collegiate Mathematics VIRTUAL CONFERENCE ictcm.com | #ICTCM ENHANCING A PROBABILITY THEORY COURSE USING R RYAN RAHRIG, PH.D. ASSOCIATE PROFESSOR OF STATISTICS OHIO NORTHERN UNIVERSITY
32nd International Conference on Technology in Collegiate Mathematics
ictcm.com | #ICTCM
VIRTUAL CONFERENCE
RYAN RAHRIG, PH.D. ASSOCIATE PROFESSOR OF STATISTICS OHIO NORTHERN UNIVERSITY
… the proportion of times the outcome would occur in a very long series of repetitions
…the long term proportion in which a certain outcome is observed
…the stable long-term relative frequency
people share the same birthday?
) ( 1 ) 1 ( = − = ≥ X P X P 365 343 365 363 365 364 365 365 1 × × × × − =
23 23 365
365 1 P − = 507297 . ≈
students “see” the concept of probability.
conducted many, many times?
Bdays <- sample(1:365, size=n, replace=TRUE)
elements D <- diff(sort(Bdays))
Results[i] <- any(D==0)
n <- 23 Results <- numeric(1000000) for(i in 1:1000000) { Bdays <- sample(1:365, size=n, replace=TRUE) # Get n birthdays D <- diff(sort(Bdays)) Results[i] <- any(D==0) } mean(Results) # proportion in Results that are TRUE
First execution: [1] 0.507737 Second execution: [1] 0.507253 ***Recall exact value: 0.507297
to end there.
Difficult to solve analytically Simple to simulate using R
each other)?
Results[i] <- any(D==0) to Results[i] <- any(D<=1) *
*Also need to handle case of Dec. 31 and Jan 1
birthday? Modify D <- diff(sort(Bdays)) Results[i] <- any(D==0) to D <- diff(sort(Bdays),lag = 2) Results[i] <- any(D==0)
for their projects.
questions.
them.
Engineer at Marathon Petroleum wanted this problem solved:
drawings?
Context: There are certain pipeline systems that administer a ‘lottery’ system where 125 shippers
If shipper wins 9 months in a row good for shipper, bad for Marathon… For x = 1, 2,…, 125, By knowing the probability that x could graduate (win 9 months in a row) with 200 new shippers, we can use those probabilities to manage the risk.
When given this problems, students tend to go with their first inclination: ENUMERATE Suppose x=5. There are total possible outcomes and determining how many of these result in exactly 5 winning all 9 months gets out of hand very quickly. Before students give up, get them to think about whether the Marathon engineer needs a nice exact answer or if a very good approximation will do the job. ( ) 9
56 9
10 * 6885 . 1 125 200
≈
Using R to approximate the probability again allows the student to more literally follow the definition of probability. Coding the simulation forces the student to articulate the experiment in detail since the idea is to repeat the experiment many, many times.
L <- matrix(, nrow = 9, ncol = 125) for (i in 1:9) { L[i,] <- sample(1:200,size=125) }
Snippet of possible L:
Count how many times each number appears: T<-table(L) Count how many were picked all 9 times (and save that for later): numWon9[k] <- sum(T==9)
Repeat the procedure many, many (nsim) times by wrapping it in a for loop: for (k in 1:nsim) { L <- matrix(, nrow = 9, ncol = 125) for (i in 1:9) { L[i,] <- sample(1:200,size=125) } T<-table(L) numWon9[k] <- sum(T==9) }
For x = 0, 1,…, 125, compute proportion where x were selected all 9 times:
Final <- data.frame(num=0:125,Probs=0) for (x in 0:125) { Final[x+1,2] <- sum(numWon9==x)/nsim }
nsim <- 1000000 num9 <- numeric(nsim) for (k in 1:nsim) { L <- matrix(, nrow = 9, ncol = 125) for (i in 1:9) { L[i,] <- sample(1:200,size=125) } T<-table(L) num9[k] <-sum(T==9) } Final <- data.frame(num=0:125,Probs=0) for (i in 0:125) { Final[i+1,2] <- sum(num9==i)/nsim }
Having successfully found an answer, students motivated to find the exact answer.
with the matrix M being the transition matrix.
simply using the basic concept of probability and a little bit of programming.
32nd International Conference on Technology in Collegiate Mathematics VIRTUAL CONFERENCE
#ICTCM