##problem 3 a plot(dexp, xlim = c(0, 3)) ##problem 3 b plot(hist(rexp(100))) ##problem 4 b Means <- apply(matrix(rexp(100 * 20), 100), 1, mean) plot(hist(10 * (Means - 1))) ##problem 7 a dat <- rnorm(100) plot(hist(dat)) mean(dat) + c(-1, +1) * qnorm(.975) * sd(dat) / 10 ##problem 8 a ciFunc <- function(x, alpha = .05){ mean(x) + c(-1, +1) * qt(1 - alpha / 2, df = length(x) - 1) * sd(x) / sqrt(length(x)) } dat <- matrix(rnorm(20 * 9, mean = 69, sd = 3), 20) cis <- t(apply(dat, 1, ciFunc)) mean(cis[,1] < 69 & cis[,2] > 69) ##problem 8 e mean(cis[,1] < 69 & cis[,2] > 69) mean(cis[,1] < 70 & cis[,2] > 70) mean(cis[,1] < 72 & cis[,2] > 72) ##problem 8 h Means <- apply(dat, 1, mean) stem(Means) var(Means) ##theoretical variance is sigma^2 / n = 9 / 9 = 1