Overview:

The project consists of two parts:

  1. A simulation exercise.
  2. Basic inferential data analysis.

Part 1: Simulation Exercise Instructions

In this project we 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. You will investigate the distribution of averages of 40 exponentials. Note that you will need to do a thousand simulations.

Part 1.1: Simulation

Set the simulation variables

set.seed(169)
lambda <- 0.2
n <- 40

Run the simulation

mns = NULL
for (i in 1 : 1000) mns = c(mns, mean(rexp(n, lambda)))

Part 1.2: Sample Mean versus Theoretical Mean

Sample Mean:

s_mean <- mean(mns)

Theoretical Mean:

t_mean <- 1/lambda

Comparing:

cbind(t_mean, s_mean)
##      t_mean   s_mean
## [1,]      5 4.987048

Figure Sample Mean versus Theoretical Mean

hist(mns, main = "Simulated Exponential Sample Means", col = "lightyellow", breaks = 35)
abline(v = s_mean, col = "red", lwd= 8)
abline(v = t_mean, col = "blue", lwd= 5)

Part 1.3: Sample Variance versus Theoretical Variance

Sample Variance:

s_variance <- var(mns)

Theoretical Variance:

t_variance <- ((1/lambda)^2)/n

comparing:

cbind(t_variance, s_variance)
##      t_variance s_variance
## [1,]      0.625  0.6508558

Part 1.4: Distribution

hist(mns, main = "Normal Distribution", col = "lightgreen", breaks = 35)
xfit <- seq(min(mns), max(mns), length = 100)
yfit <- dnorm(xfit, mean = 1/lambda, sd = (1/lambda)/sqrt(n))
lines(xfit, yfit*200, lty = 5)

The Histogram illustrates that the Distribution is Approximately Normal