Problem 1: # Graph a binomial distribution in R. # First we compute all probabilities. # X is binomial(10,0.5), therefore, X=0,1,2,..., 10. x <- seq(0,10) px <- dbinom(x, size = 10, prob = 0.5) barplot(px, space = 0, xlab = "X", ylab = "P(X)", ylim = c(0, .25), main = "Binomial probability distribution: n=10, p=0.5", names=seq(0,10,1)) ============================================================================== Problem 2: a. X ~ B(20, 0.3). 1. pbinom(4, 20, 0.3) 2. pbinom(7, 20, 0.3, lower.tail=FALSE) 3. pbinom(5, 20, 0.3, lower.tail=FALSE) 4. pbinom(2, 20, 0.3) 5. pbinom(6, 20, 0.3) - pbinom(2, 20, 0.3) b. X ~ N(13, 2.5) 1. pnorm(16.1, mean=13, sd=2.5) 2. 1-pnorm(16.5, mean=13, sd=2.5) OR pnorm(16.5, mean=13, sd=2.5, lower.tail=FALSE) 3. pnorm(13.5, mean=13, sd=2.5) 4. pnorm(15, mean=13, sd=2.5) - pnorm(12, mean=13, sd=2.5) 5. qnorm(0.61, mean=13, sd=2.5) ============================================================================== Problem 3: We have X ~ b(b, 0.58). By trial and error, you will find that n=568. We want the probability to be at least 95% that at least 310 student will be enrolled. So we want, P(X >= 310) >= 95%. Let's begin with n=500: pbinom(309, 400, .58, lower.tail=FALSE) 0.03813603 (very small!). Let's increase to 530: pbinom(309, 530, .58, lower.tail=FALSE) 0.4275875 (still not close to 95%). Let's increase to 560: pbinom(309, 560, .58, lower.tail=FALSE) 0.9046458 (much closer to 95%). Try n=570: pbinom(309, 570, .58, lower.tail=FALSE) 0.9629718 (this is above 95%). Try now, n=567 pbinom(309, 567, .58, lower.tail=FALSE) 0.9498989 (a little bit below 95%). Finally, use n=568: pbinom(309, 568, .58, lower.tail=FALSE) 0.9546223 (this satisfies "at least 95 %"). Important: Ask the students to think about it, by giving them the following hint: Another way to answer this question is to set up an equation using normal approximation to binomial. How? -1.645 = (309.5 - n*0.58) / sqrt(n*0.58*0.42), and solve for n. ============================================================================== Problem 4: It is given that X ~ N(3, 0.3). a. pnorm(2.5, mean=3, sd=0.3) b. pnorm(3.2, mean=3, sd=0.3) - pnorm(2.5, mean=3, sd=0.3) c. pnorm(3.2, mean=3, sd=0.3, lower.tail=FALSE) ============================================================================== Problem 5: This is binomial with n=275, p=0.95. Exact probability: P(X >265) = sum(x=265 to 275) (275 choose x) * 0.95^x * 0.05^(275-x) Approximate using normal: P(X > 265) = P(Z>265.5 - n*p) / (n*p*(1-p))^0.5 where np=275*0.95=261.25 and (n*p*(1-p))^0.5 = (275*0.95*0.05)^0.5=3.614208. Therefore, P(X > 265) = P(Z > 265.5-261.25 / 3.614208) = P(Z>1.175915) Using R - exact: pbinom(265, 275, 0.95, lower.tail=FALSE) Answer: 0.1155464 Using R - approximate: pnorm(265.5, mean= 261.25, sd= 3.614208, lower.tail=FALSE) Answer: 0.1198145 Exact and approximate are very close.