Project - Statistical Inference - part 1
Sergio Vicente Simioni
May, 18, 2015
This project 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. It will be investigated the distribution of averages of 40 exponentials.
Expo_Distr <- NULL
lambda<- 0.2
z<- 40
d<- 1000
for ( i in 1:d)
Expo_Distr <- c(Expo_Distr, mean(rexp(z,lambda)))
theorectical_mean<- mean(rexp(d,lambda))
sample_mean<- mean(Expo_Distr)
print(theorectical_mean)
## [1] 4.957975
print(sample_mean)
## [1] 5.013667
theorectical_variance <- var(rexp(d,lambda))
sample_variance<- var(Expo_Distr)
print(theorectical_variance)
## [1] 22.69022
print(sample_variance)
## [1] 0.6174074
z<- Expo_Distr
k<- rexp(1000, 0.2)
par(mfrow=c(1,2))
b<- hist(rexp(k, lambda), breaks=10, col="red", main= " Exponential Distribution",
xlab=expression(paste( ,mu, " ~ 5" ," ", sigma^2, " ~ 25")))
abline(v = theorectical_mean, col = "blue", lwd = 2)
a<- hist(z, prob=T, breaks=10, col="red", main= " Sample Mean Distribution",
xlab=expression(paste( ,hat(x), " ~ 5" ," ", hat(s)^2, " ~ 25/40")))
abline(v = sample_mean, col = "blue", lwd = 2)
lines(density(z, bw=.5),col = "blue", lwd = 1)
The exponential distribution graphic on the left was built with 1000 values and lambda = 0.2, its mean and variance are approximately 1/lambda and 1/(lambda^2) respectively ( ~ 5 and ~ 25). At the right was built a new distribution utilizing the mean of the samples from the exponential distribution, it is amazing to observe that the new distribution is normal, which mean is also ( ~ 5 ) and its variance has a proportionality with the population variance which is inversely proportional to the sample size, for this case the variance is (1/(lambda^2))/(size of samples) which represents 25/40 ~ 0.6.
May/19/15 SVS