# Central Limit Theorem Demonstration # set up plot window plot(0, 0, type="n", xlim=c(0,1), ylim=c(0, 15.5), main="CLT for n=2,10,25,100", xlab="Density estimate", ylab="f(x)") # create plots m <- 500 ; a <- 0 ; b <- 1 res <- c() ; n <- c(2, 10, 25, 100) for(i in 1:4) { for(j in 1:m) { res[j] <- mean(runif(n[i], a, b)) } lines(density(res), lwd=2) }