q: The exponential distribution can be simulated in R with rexp(n, lambda) where lambda is the rate parameter. The mean of exponential distribution is 1/lambda and the standard deviation is also also 1/lambda. Set lambda = 0.2 for all of the simulations. In this simulation, you will investigate the distribution of averages of 40 exponential(0.2)s. Note that you will need to do a thousand or so simulated averages of 40 exponentials. …
x<-NULL;n<-1000;lambda<-0.2;n<-40;times<-1000;
for(i in 1:times)
{
x <- c(x, mean(rexp(n,lambda)))
}
hist(x)
S<-var(x)
S2<-1/(0.2^2)/40
d<-density(x)
plot(d)
ci<-NULL
ci<-c(mean(x)-1.96*S^(1/2)/n^(1/2))
ci<-c(ci,(mean(x)+1.96*S^(1/2)/n^(1/2)))
ci
## [1] 4.795 5.281