This report uses simulation to investigate the exponential distribution in R and to illustrate the Central Limit Theorem (CLT). We simulate 1,000 averages of 40 exponential random variables (rate \(\lambda = 0.2\)), then compare the resulting sample mean and sample variance to their theoretical counterparts, and show that the distribution of these averages is approximately Normal even though the underlying exponential distribution is highly skewed.
The exponential distribution has theoretical mean \(1/\lambda\) and standard deviation \(1/\lambda\) (so variance \(1/\lambda^2\)). With \(\lambda = 0.2\), the theoretical mean is
\(5\) and the theoretical variance is
\(25\). We draw 40 exponential values,
take their average, and repeat this 1,000 times, storing each average in
mns. By the CLT, the distribution of these 1,000 averages
should be approximately Normal with mean \(1/\lambda = 5\) and variance \(\frac{(1/\lambda)^2}{n} = \frac{25}{40} =
0.625\).
set.seed(1)
lambda <- 0.2
n <- 40
nosim <- 1000
mns <- NULL
for (i in 1:nosim) {
mns <- c(mns, mean(rexp(n, lambda)))
}
theo_mean <- 1 / lambda
theo_var <- (1 / lambda)^2 / n
The theoretical mean of the distribution of averages is \(1/\lambda = 5\). The simulated sample mean across the 1,000 simulations is 4.99, which is extremely close to the theoretical value — the small discrepancy is sampling variability that would shrink further with more simulations (a direct consequence of the Law of Large Numbers).
hist(mns, breaks = 30, col = "lightblue", probability = TRUE,
main = "Distribution of Averages of 40 Exponentials",
xlab = "Sample mean")
curve(dnorm(x, mean = theo_mean, sd = sqrt(theo_var)), add = TRUE, lwd = 2)
abline(v = mean(mns), col = "red", lwd = 2)
abline(v = theo_mean, col = "darkgreen", lwd = 2, lty = 2)
legend("topright", legend = c("Sample mean", "Theoretical mean"),
col = c("red", "darkgreen"), lty = c(1, 2), lwd = 2, bty = "n", cex = 0.8)
Distribution of 1000 averages of 40 exponentials, with the sample mean (red) and theoretical mean (green, dashed) marked.
The theoretical variance of the distribution of averages of 40 exponentials is \(\frac{(1/\lambda)^2}{n} = 0.625\). The simulated sample variance of the 1,000 averages is 0.611, again very close to the theoretical value. This agreement confirms that averaging reduces variability by a factor of \(n\) relative to a single exponential draw (whose theoretical variance is \(25\)): averaging 40 observations shrinks the variance from \(25\) down to roughly \(0.625\), a \(40\)-fold reduction, exactly as predicted by the formula \(\text{Var}(\bar X) = \sigma^2 / n\).
boxplot(mns, main = "Spread of the 1000 Sample Means", ylab = "Sample mean", col = "lightyellow")
abline(h = theo_mean, col = "darkgreen", lwd = 2, lty = 2)
mtext(paste0("Sample var = ", round(var(mns),3), " Theoretical var = ", theo_var), side = 3, cex = 0.8)
Although a single exponential random variable is strongly right-skewed, the CLT tells us that the distribution of the average of many such variables approaches a Normal distribution as \(n\) grows. Figure 3 (Appendix) contrasts 1,000 individual exponential draws — clearly skewed — with the 1,000 averages of 40 exponentials, which are roughly bell-shaped and symmetric around 5. The Normal Q-Q plot (Figure 4, Appendix) reinforces this: the points fall close to the reference line across most of the range, with only minor deviation in the extreme tails, consistent with approximate (not exact) normality for a finite \(n = 40\).
This analysis assumes: (1) the 40 exponential draws within each simulation are independent and identically distributed with rate \(\lambda = 0.2\); (2) \(n = 40\) is large enough for the CLT approximation to be reasonable, though the approximation is imperfect in the tails since the underlying distribution is skewed; (3) 1,000 simulations is enough to estimate the sampling distribution’s mean and variance with reasonably low Monte Carlo error.
par(mfrow = c(1, 2))
hist(rexp(1000, lambda), breaks = 30, col = "orange",
main = "1000 random exponentials", xlab = "x")
hist(mns, breaks = 30, col = "lightblue",
main = "1000 averages of 40 exp.", xlab = expression(bar(x)))
Figure 3: A single exponential draw is right-skewed (left); the distribution of averages of 40 exponentials is approximately bell-shaped (right) – the essence of the CLT.
par(mfrow = c(1, 1))
qqnorm(mns, main = "Normal Q-Q Plot of Sample Means")
qqline(mns, col = "red", lwd = 2)
Figure 4: Normal Q-Q plot of the 1000 sample means.
summary(mns)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.108 4.445 4.950 4.990 5.492 7.491