In [1]:
seq1 <- seq(100, 1000, by=100)
seq2 <- seq(1200, 2000, by=200)
In [2]:
for (n in c(1, 2, 3, 5, 10, 50, seq1, seq2)) {
result <- c()
mu <- sigma <- 10
for (i in 1:5000) {
X <- rexp(n, 1/mu)
result[i] <- (mean(X)-mu)/(sigma/sqrt(n))
}
his <- hist(result, breaks=seq(min(result)-1, max(result)+1, by=0.25), plot=FALSE)
ylim <- range(his$density, dnorm(0))
hist(result, breaks=seq(min(result)-1, max(result)+1, by=0.25),
prob=TRUE, ylim=ylim, main=paste("n=", n))
x <- seq(-4, 4, by=0.1)
lines(x, dnorm(x), lty=1, lwd=2, col="red")
}