Overview

In this report we explore the threshold beyond which the Central Limit Theorem becomes a good approximation for the distribution of sample averages of exponentially distributed random variables. The sample size is 40 and we calculate the sample average for 1000 samples. We will then examine the simulated sample mean distribution and compare it against the theoretical normal distribution centered aroud the population mean.

Simulations

We begin by defining the relevant parameters for the simulation and loading the relevant packages

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.3
lambda=0.2
pop_mean=1/lambda
pop_sd=1/lambda
n=40
popm_sd=1/(lambda*sqrt(n))
nsim=1000

and the function to calculate the standardized sample mean

stdm = function(x) (mean(x)-pop_mean)/popm_sd

We then create the 1000X40 matrix of 1000 random samples with one sample per row

set.seed=(123)
mat = matrix(rexp(n*nsim,lambda),nsim,n)

from which we calculate the standardized sample mean for each sample by applying the stdm function to each row

stdmvec= apply(mat,1,stdm)

We now plot a histogram of the sample means in order to visualize their ‘empirical’ distribution

In order to better visualize how the simulated distribution compares to a theoretical normal distribution we make a density plot

From the density plot one can see that the sample mean distribution fits quite well a Gaussian distribution as it is also confirmed by the quantile plot

Sample parameters vs theoretical parameters

Having established that the sample means follow approximately a normal distribution, we now want to make sure that the first and second momentum of this approximate Gaussian coincide with the theoretical values.

We begin by checking whether the difference between the sample average mean (i.e. the mean of the sample means) and the theoretical mean is consistent with zero within a 95% confidence interval, or, in other words, if the simulated (approximately) normal distribution is compatible with zero mean

t.test(stdmvec)
## 
##  One Sample t-test
## 
## data:  stdmvec
## t = 0.34394, df = 999, p-value = 0.731
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  -0.05079025  0.07237814
## sample estimates:
##  mean of x 
## 0.01079395

As we can see, it is largely compatible within any reasonable confidence interval.

Checking in a rigorous way whether the simulated and theoretical distributions have the same standard deviation is less straightforward. For this reason we will limit ourselves to compute the difference between the two and, assuming that such difference is normally distributed with zero mean and unitary standard deviation, check if the actual value is compatible with this hypothesis within 95% confidence interval.

 mmean=mean(stdmvec)
ssd=sqrt(sum((stdmvec-mmean)^2)/nsim)
pnorm(ssd)
## [1] 0.8393821

From our analysis we can thus conclude that,given the exponential distribution and its parameters, a sample of size n=40 allows a reasonable approximation of the asymptotic regime.