# Example 1.1 # ================== # X ~ N(10, 1.5^2) # (1) Find P(8 < X <12) pnorm(12, mean=10, sd=1.5) - pnorm(8, mean=10, sd=1.5) # 0.8176 # (2) Find P(X > 13 | X >6) (1-pnorm(13, 10, 1.5))/(1-pnorm(6, 10, 1.5)) # 0.0228 # Example 1.2 # ================= x <- scan() 80 80 79 81 76 66 71 76 70 85 x.bar <- mean(x) s2 <- var(x) sd <- sqrt(var(x)) qt(.95, 9) # 1.833113 qt(.975, 9) # 2.262157 # 95% Confidence Interval result1 <- t.test(x, alternative="two.sided", conf.level=0.95) names(result1); result1$conf.int # 72.22606 80.57394 # One-Sided t Test result2 <- t.test(x, alternative="greater", mu=75, conf.level=0.95); result2 cbind(t= result2$statistic, df=result2$parameter, p.value=result2$p.value) -------------------------------------------------------------- One Sample t-test data: x t = 0.7588, df = 9, p-value = 0.2337 alternative hypothesis: true mean is greater than 75 95 percent confidence interval: 73.0177 Inf sample estimates: mean of x 76.4 t df p.value t 0.7587608 9 0.2337003 -----------------------------------------------------------------