Overview

In this project we 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 \(\sigma\) is also \(1/\lambda\). Set \(\lambda\) = 0.2 for all of the simulations. We investigate the distribution of averages of 40 exponentials.

Simulations

First, we simulate 1000 random sampling of 40 exponentials with \(\lambda\) = 0.2.

Next, we compute calculate sample mean \(\bar{x}\) generated from each sampling of n=40

We will perform analyses on the simulated samples to show:
1. the sample mean and compare it to the theoretical mean of the distribution.
2. how variable the sample is (via variance) and compare it to the theoretical variance of the distribution.
3. that the distribution is approximately normal.

Analysis

Sample Mean

Considering the distribution of the mean of 40 exponentials. Because the mean is an unbiased estimator and is consistent, the sample mean of this distribution converges to the population mean of the initial exponential distribution. Thereby the theoretical mean of this distribution is \(\mu\) = 1/\(\lambda\) = 5.
Calculate the simulated sample mean

## [1] 4.971972

Which is very close to the theoritical mean of exponential distribution \(\mu\) = 5
Next, we plot the density of the sample means.
From the figure above, it’s easy to see that the average sample mean of 40 exponential random variables with rate \(\lambda\) = 0.2 is the redline which is very close to the theoritical mean of the exponential distribution \(\mu\) = 5.

Sample Variance

The theoritical value for the varaince of the distribution of sample means of size n is:
\(var(\bar{X})\) = \(\frac{\sigma^2}{n}\) = \(\frac{1}{40\lambda^2}\) = \(0.625\)
We calculate the simulated sample variance of the sample mean:

## [1] 0.6157926

The variance of sample mean is close to but not equal the theoritical variance.
We can repeat the simulation 100 times and graph the distribution of sample mean and sample variance each time.
The mean of sample means is 4.9999331 and the mean of sample variances is 0.6246563 which are very close to the theoritical mean (5) and variance (0.625).

Distribution

The Central Limit Theorem (CLT) states that The Central Limit Theorem (CLT) states that the distribution of means of independent and identically distributed(iid) variables becomes that of a standard normal as the sample size increasese.
Based on the result from Analysis Step 1 - perform the following hypothethis testing \(H_0\): the distribution of averages of sample mean is normal with mean \(\mu\) = 1/\(\lambda\) and standard deviation \(\sigma\) = 1/\(\lambda\)\(\sqrt{40}\)
The test stastic \(Z\) and p-value are:

## [1] 0.03545297 0.97171855

The high p-value suggests that we fail to reject the null hypothesis. Hence the distribution of average of sample mean is standard normal.

Appendix - R code for graphs