The exponential distribution is given as lambda * e-(lambda *x)
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.
set.seed(0)
rate <- 0.2
samples <- 40
nosims <- 1000
x <- replicate(nosims,mean(rexp(samples,rate))) #vector containing means of 40 samples repeated 1000 times
The theoretical mean of the exponential distribution is calculated as 1/lambda.
lambda = 0.2, hence mean = 1/0.2 = 5
As the distribution of averages of the sample estimates the mean of the random variable distribution, the theoretical mean is simply 5.
mean(x)
## [1] 4.989678
The theoretical variance of the exponential distribution is (1/lambda)2
(1/.2)2 = 25
The variance of the averages of the sample distribution is (variance of random variable distribution)/n = 25/40 = 0.625 And theoretical standard deviation is 0.7905
var(x)
## [1] 0.6181582
sd(x)
## [1] 0.7862304
First let's simulate the distribution of a 1000 random exponentials.
library(ggplot2)
y <- rexp(1000,rate)
xy <- data.frame(x,y)
plot(ggplot(xy,aes(x=y))+geom_histogram(aes(y=..density..),binwidth=1,color="black",fill="white")+stat_function(fun=dexp, args=list(rate=0.2))+labs(title="Distribution of 1000 random exponentials"))
Now let's simulate the distribution of 1000 averages of 40 samples of exponentials.
plot(ggplot(xy,aes(x=x))+geom_histogram(aes(y=..density..),binwidth=0.1,color="black",fill="white")+stat_function(fun=dnorm, args=list(mean=mean(x),sd=sd(x)))+geom_vline(xintercept=mean(x),color="red",lwd=1.2)+labs(title="Distribution of 1000 averages of 40 samples of exponentials")+geom_text(aes(x=mean(x)+0.2,y=-0.01,label=round(mean(x),2)),color="red",size=4)+geom_vline(xintercept=mean(x)+1.96*c(-1,1)*sd(x),color="blue")+geom_text(aes(x=mean(x)+0.2+2*sd(x),y=-0.01,label=round(mean(x)+2*sd(x),2)),color="blue",size=4)+geom_text(aes(x=mean(x)-0.2-1.96*sd(x),y=-0.01,label=round(mean(x)-1.96*sd(x),2)),color="blue",size=4))
This plot shows the mean and 95% confidence interval of the distribution of 1000 averages of 40 samples of exponentials
It is clear from the plots above, that the distribution of a large collection of means of exponentials approximates to a normal distribution. The mean of this distribution estimates the mean of the original exponential distribution.