The project consists of two parts:
In this project we will investigate the exponential distribution in R and compare it with the Central Limit Theorem. 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 1/lambda. Set lambda = 0.2 for all of the simulations. You will investigate the distribution of averages of 40 exponentials. Note that you will need to do a thousand simulations.
set.seed(169)
lambda <- 0.2
n <- 40
mns = NULL
for (i in 1 : 1000) mns = c(mns, mean(rexp(n, lambda)))
Sample Mean:
s_mean <- mean(mns)
Theoretical Mean:
t_mean <- 1/lambda
Comparing:
cbind(t_mean, s_mean)
## t_mean s_mean
## [1,] 5 4.987048
hist(mns, main = "Simulated Exponential Sample Means", col = "lightyellow", breaks = 35)
abline(v = s_mean, col = "red", lwd= 8)
abline(v = t_mean, col = "blue", lwd= 5)
Sample Variance:
s_variance <- var(mns)
Theoretical Variance:
t_variance <- ((1/lambda)^2)/n
comparing:
cbind(t_variance, s_variance)
## t_variance s_variance
## [1,] 0.625 0.6508558
hist(mns, main = "Normal Distribution", col = "lightgreen", breaks = 35)
xfit <- seq(min(mns), max(mns), length = 100)
yfit <- dnorm(xfit, mean = 1/lambda, sd = (1/lambda)/sqrt(n))
lines(xfit, yfit*200, lty = 5)
The Histogram illustrates that the Distribution is Approximately Normal