Author: Sergio V. Simioni
date: August/10/2015
Benefits:
Presentation Proposal
**
This project aims to demonstrate the ability to run embedded R code,through the investigation of an exponential distribution in R comparing it with the Central Limit Theorem. The exponential distribution was 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. lambda was set = 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)
theorectical_variance <- var(rexp(d,lambda))
sample_variance<- var(Expo_Distr)
print(theorectical_mean)
[1] 5.200037
print(sample_mean)
[1] 4.972113
print(theorectical_variance)
[1] 27.74256
print(sample_variance)
[1] 0.6482529
The exponential distribution was built with 1000 values and lambda = 0.2, its mean and variance are approximately 1/lambda and 1/(lambda2) respectively ( ~ 5 and ~ 25). At the same time the distribution utilizing the mean of the samples from the exponential 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/(lambda2))/(size of samples) which represents 25/40 ~ 0.6