# Demo of CLT using uniform random variables
# We'll make a matrix of samples of uniform random variables
# Each sample has n observations, and there are I samples
# Also try
# > install.packages("TeachingDemos")
# > library(TeachingDemos)
# > help(clt.example)
# > clt(n=2,reps=10000,nclass=100)
I <- 10000
n <- 2
obs <- runif(I*n)
obs <- matrix(obs,nrow=I)
head(obs)
#rowMeans calculates the mean for each row
#and puts it in a vector
means <- rowMeans(obs)
hist(means,breaks=100,ylab="xbar",cex.lab=1.3,
cex.axis=1.3,main="")