Rudolf Adamkovič Personal site


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)

© 2025 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.