Home / Descriptive statistics / Central limit theorem
Exploration in R
The sample mean of \(N = 10^3\) samples taken from a uniformly distributed population should distribute normally.
set.seed(0)
N <- 10^4
Z <- rep(1, N)
for(i in 1 : N) {
X <- runif(10^3)
Z[i] <- mean(X)
}
Y <- density(Z)
plot(
main = "A demonstration of the central limit theorem.",
Y,
type = "l",
lwd = 2,
xlab = "Sample mean",
ylab = "Density"
)
abline(v = 0.5)