Title

Exponential Distribution Investigation

Overview

This analysis will investigate the exponential distribution in R and compare it with the Central Limit Theorem. We will simulate 1000 runs of the exponential distribution and compare sample results to population calculations to see how close they are to each other.

Simulations

The simulation below will run 1000 random exponential distributions of 40 samples with lambda of 0.2. We will then take the mean of each distribution. With this simulation, we are hoping to approximate the mean of the true population.

n=40
lambda = 0.2

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

Sample Mean versus Theoretical Mean

This section will compare the population and sample means. As shown below, the population mean is 5, and the sample mean is very close to 5, with a very small difference between the population and sample means. The difference in means is due to a slightly different variance in the sample distribution. The close result, however, is expected from the Central Limit Theorem.

Theoretical mean

1/lambda
## [1] 5

Sample mean

mean(mns)
## [1] 4.992613

Difference between theoretical and sample means

1/lambda - mean(mns)
## [1] 0.007387077

Sample Variance versus Theoretical Variance

This section will explore the sample variance versus the theoretical variance. We would expect the variances to be close, but not exactly equal due to the randomness in the simulation.

Theoretical vairance

popvar <- ((1/lambda)^2)/n
popvar
## [1] 0.625

Sample variance

sampvar <- var(mns)
sampvar
## [1] 0.6048352

Variance difference

popvar - sampvar
## [1] 0.02016475

Distribution

This section will compare the distribution of one random distribution of n = 40 and lambda = 0.2 versus the mean of 1000 runs of the random distribution with the sample parameters. You can see the disribution of the means is approximately normally distributed, with an deven distribution around the mean on both sides, and a bell shaped curve.

Distribution of One Simulation

hist(rexp(n, lambda), main="Histogram of One Simulation")

plot of chunk unnamed-chunk-8

Distribution of the Mean of 1000 Simulations

hist(mns, main="Histogram of the Mean of 1000 Simulations")

plot of chunk unnamed-chunk-9