Overview

This report investigates the exponential distribution in R and compares 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. This report investigates the distribution of averages of 40 exponentials. There will be a thousand (1,000) simulations.

This report will show via simulation and associated explanatory text the properties of the distribution of the mean of 40 exponentials. The following questions are addressed:

  1. What is the sample mean? Compare it to the theoretical mean of the distribution.
  2. How variable is the sample (via variance)? Compare it to the theoretical variance of the distribution.
  3. Is the distribution is approximately normal? Show it in a graph.

Set-up

# set constants
lambda <- 0.2  # lambda for rexp
n <- 40         # number of exponetials
nosim <- 1000   # number of simulations
set.seed(212)       # for reproducibility

# exponential distribution and mean in R
edis <- replicate(nosim, rexp(n,lambda))
emean <- apply(edis,2,mean)

Question 1: What is the sample mean? Compare it to the theoretical mean of the distribution.

# compare distribution mean and theoretical mean
dmean <- mean(emean)
dmean 
## [1] 4.992587
tmean <- 1/lambda
tmean
## [1] 5

The distribution (sample) mean is 4.992587 whereas the theoretical (expected) mean is 5, which are rather close in value. This is a good sign!

Question 2: How variable is the sample (via variance)? Compare it to the theoretical variance of the distribution.

# standard deviation of distribution
sdd <- sd(emean)
sdd
## [1] 0.8017164
# standard deviation (theoretical)
sdt <- (1/lambda)/sqrt(n)
sdt
## [1] 0.7905694
# distribution variance
vd <- sdd^2
vd
## [1] 0.6427492
# theoretical variance
vt <- ((1/lambda) * (1/sqrt(n)))^2
vt
## [1] 0.625

Both the standard deviation of the distribution (sample) and theory (expected) as well as the variance of the distribution and theory are really close. For standard deviation, the sample is approximately 0.80 and the expected is approximately 0.79. For variance, the sample is approximately 0.6427 and the expected is approximately 0.625.

Question 3: Is the distribution is approximately normal? Show it in a graph.

The distribution (sample) is approximately normal. According to the Central Limit Theorem, the distribution (sample) of averages of 40 exponentials is close to a normal distribution (expected). In the graph above, the red vertical line represents the mean for the distribution (sample) and the blue vertical line represents the mean for the theory (expected). The smooth black line shows that the sample resembles that of a normal distribution.