- States that the distribution of the sample mean approximates a normal distribution
- This happens regardless of the population distribution.
- Is one of the most important concepts in probability statistics.
2025-10-19
If \(X_1, X_2, ..., X_n\) are independent, identically distributed random variables with mean \(\mu\) and variance \(\sigma^2\), then:
\[ \bar{X}_n = \frac{1}{n} \sum_{i=1}^{n} X_i \] approaches:
\[ \bar{X}_n \sim N\left(\mu, \frac{\sigma^2}{n}\right) \]
# Define population: exponential distribution (clearly not normal)
population <- rexp(100000, rate = 1)
# Function to sample and compute means
sample_means <- function(n, reps = 1000) {
replicate(reps, mean(sample(population, n, replace = TRUE)))
}
n_values <- c(2, 5, 30)
means_list <- lapply(n_values, sample_means)
names(means_list) <- paste0("n=", n_values)
ggplot(data.frame(x = population), aes(x)) +
geom_histogram(bins = 40, fill = "#8C1D40", color = "white") +
labs(title = "Original Population: Exponential Distribution",
x = "Value", y = "Frequency")
means_df <- data.frame(
mean = c(means_list[[1]], means_list[[2]], means_list[[3]]),
n = factor(rep(n_values, each = 1000))
)
ggplot(means_df, aes(x = mean, fill = n)) +
geom_histogram(bins = 30, color = "white", alpha = 0.7, position = "identity") +
labs(title = "Sampling Distributions for Different Sample Sizes",
x = "Sample Mean", y = "Frequency") +
facet_wrap(~n, scales = "free")
plot_ly( x = means_df$mean, y = as.numeric(means_df$n), z = rep(1:1000, length(n_values)), type = "scatter3d", mode = "markers", marker = list(size = 3, color = means_df$mean, colorscale = "Viridis") ) %>% layout(title = "Central Limit Theorem: 3D Visualization")
As \(n\) increases, variance decreases:
\[ Var(\bar{X}_n) = \frac{\sigma^2}{n} \]
and the distribution of \(\bar{X}_n\) becomes more concentrated around \(\mu\).
Thus, for large \(n\):
\[ Z = \frac{\bar{X}_n - \mu}{\sigma / \sqrt{n}} \sim N(0,1) \]
# Example of computing sample means for CLT visualization
sample_means <- function(n, reps = 1000) {
replicate(reps, mean(sample(rexp(100000, 1), n, replace = TRUE)))
}
means_30 <- sample_means(30)
hist(means_30, main="Sampling Distribution (n=30)",
col="#8C1D40", border="white")