Comparison of Exponential Distribution and Central Limit Theorem
Introduction
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.3
Simulation
set.seed(0901)
n <- 40
lmd <- 0.2
rep <- 1000
simulations <- replicate(rep, rexp(n, lmd))
Sample Mean versus Theoretical Mean
each.mean <- apply(simulations, 2, mean)
real.mean <- mean(each.mean)
real.mean
## [1] 4.981791
theo.mean <- 1/lmd
theo.mean
## [1] 5
hist(each.mean, xlab = "Mean of Simulations", main = "Simulated Exponential Functions")
abline(v = real.mean)
abline(v = theo.mean)

Sample Variance versus Theoretical Variance
real.sd <- sd(each.mean)
real.var <- real.sd^2
real.sd
## [1] 0.7564694
real.var
## [1] 0.572246
theo.sd <- 1/lmd/sqrt(n)
theo.var <- theo.sd^2
theo.sd
## [1] 0.7905694
theo.var
## [1] 0.625
Distribution
means <- seq(min(each.mean), max(each.mean), length = rep)
density <- dnorm(means, mean = theo.mean, sd = theo.sd)
hist(each.mean, breaks = n, prob = TRUE, main = "Density of Means")
lines(means, density)

qqnorm(each.mean)
qqline(each.mean)
