In this project, one exponential distribution is simulated and campared with the Central Limt Theorem. 1000 simulations with 40 exponential. Lambda is seted to be 0.2. The mean and the standard deviation are the same, 1/lamda, which is equal to 5.
Via simulation and associated explanatory text, the following 3 points are showed in this document:
The exponential distribution is 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. For constistence, a seed is set as 1234.
library(ggplot2)
set.seed(1234)
n <- 1000
lambda<- 0.2
B<- 40
#Stimulation
Sti <- matrix(rexp(n * B, rate=lambda), n, B)
mns <- rowMeans(Sti)
hist(mns, breaks=20)
The theretical mean is 1/lambda
SM<- mean(mns)
TM<- 1/lambda
SM;TM
## [1] 4.974239
## [1] 5
So, the sample mean and theretical mean is close to 5.
The theretical is (1/lambda)^2
SV<- var(mns)
TV<- (1/lambda)^2/B
SV;TV
## [1] 0.5949702
## [1] 0.625
From this compare, we can see that the variances is slightly different, but close.
hist(mns, breaks=20)
abline(v=TM, col="red",lwd=5)
qqnorm(mns);qqline(mns)
It looks that the stimulated line is liniar.