The project investigates the exponential distribution in R and compares it with the Central Limit Theorem. The project illustrates via simulation and associated explanatory text the properties of the distribution of the mean of 40 exponentials by the means of:
A simulation exercise. Basic inferential data analysis.
set.seed(2016)
#Set lamdba
lambda <- 0.2 # according to guidelines
# Simulations
sim <- 1000
# Samples
n <- 40
We calculate both as shown below:
## [1] 4.979186
## [1] 5
The simulated mean is 4.98, compared to the calculated theoretical mean of 5.
#Sample Mean versus Theoretical Mean
Sim_Std_Dev <- sd(Mean_Eval)
Var<-Sim_Std_Dev^2
Var
## [1] 0.6384844
# Theoretical Standard Deviation and Variance
Th_Std_Dev<-(1/lambda)/sqrt(n)
t_Var<-Th_Std_Dev^2
t_Var
## [1] 0.625
The simulated variance is 0.63 compared to the theoretical variance of 0.625.
hist(Mean_Eval, breaks = 40, xlab = "Mean", main = "Comparison to a Normal Distribution", col = "green")
x <- seq(min(Mean_Eval), max(Mean_Eval), length = 100)
y <- dnorm(x, mean = 1/lambda, sd = 1/lambda/sqrt(n))
lines(x, y*100, lty=2)
The calculated ditribution of random samples overlaps with the normal distribution, due to the Central Limit Theorem. The mose samples we get ,more close these figures will come.