Central limit in action

600 views · Published 17 May 2012 · 0:42 · Indexed 21 September 2026

Channel: Sharon Klinkenberg · 2012 · Education

Watch on YouTube

# Central limit theorem

# Sampling numbers between 0 and 10 
# from a uniform distribution many times

# R code

means = vector() # creating vector to store means
samples = 1000 # number of samples 
sample_size = 100 # the sample size

for(i in 1:samples) {
 
 means[i] = mean(runif(sample_size,0,10))
 
 hist(means,breaks=seq(4,6,.1),xlim=c(4,6),ylim=c(0,samples/6), col="red",main="Central limit theorem in action",xlab="Means of uniform samples")
 
 legend("topright",legend=paste(i,"samples"),bty="n")
 
 }

More from this channel