In this document we will demonstrate the validity of Central Limit Theorem (CLT) on Exponential Distributions using simulations. More specifically, we will simulate 1000 expontential distributions of 40 items each.
We will create 1000 exponential distributions. Each distribution will have 40 items with mean lambda = 0.2. For this value of lambda, the theoretical mean is 1/lambda = 5. The chart below depicts the histogram of the simulated means from the 1000 distributions and also the theoretical mean.
As can be seen the means look normally distributed (around the theoretical mean), confirming to the CLT.
set.seed(100)
lambda = 0.2
theoretical_mean = 1/lambda
expmeans <- NULL
for (i in 1:1000) {
expmeans = c(expmeans, mean(rexp(40, lambda)))
}
hist(expmeans, breaks = 50, xlab = "Simulated Means", main = "Histogram of Simulated Means")
abline(v = theoretical_mean ,col = "red")
legend("topright", c("Simulated","Theoretical"), lty = c(1,1), lwd=c(2.5,2.5),col=c("black","red"))
We will create 1000 exponential distributions. Each distribution will have 40 items with mean lambda = 0.2. For this value of lambda, the theoretical variance is 1/lambda^2 = 25. The chart below depicts the histogram of the simulated variance from the 1000 distributions and also the theoretical variance.
As can be seen the variance look normally distributed (around the theoretical variance), confirming to the CLT.
To test the normality of the distributions, we can test that using overlapping the above histograms with simulated normal distributions. On the both charts below, we can see that the simulated distributions match closely with normal distributions centered around the means of the simulated distributions.
hist(expmeans, breaks = 50, prob = TRUE, xlab = "Simulated Means", main = "Histogram of Simulated Means")
xsequence <- seq(min(expmeans), max(expmeans), length=50)
ynormalmeans <- dnorm(xsequence, mean=theoretical_mean, sd=1)
lines(xsequence, ynormalmeans, col = 'red', lwd = 2)
legend("topright", c("Simulated","Normal Dist"), lty = c(1,1), lwd=c(2.5,2.5),col=c("black","red"))
hist(expvars, breaks = 50, prob = TRUE, xlab = "Simulated Variance", main = "Histogram of Simulated Variance")
xsequence <- seq(min(expvars), max(expvars), length=50)
ynormalvars <- dnorm(xsequence, mean=theoretical_variance, sd=10)
lines(xsequence, ynormalvars, col = 'red')
legend("topright", c("Simulated","Normal Dist"), lty = c(1,1), lwd=c(2.5,2.5),col=c("black","red"))