# 2004 年 12 月 14 日作成 # simulation of CLT from uniform sample num.rep<-10000 # number of sample size num.sample<-3 s<-rep(0,num.rep) # # # generate sample mean # for (i in 1:num.sample){ s<-s+runif(num.rep,0,1)/num.sample } # # # drat graph of centered sample mean # plot(density(sqrt(12*num.sample)*(s-1/2)),xlim=c(-4,4),ylim=c(0,0.5),type="l",xlab="",ylab="") xx<-seq(-4,4,by=0.001) par(new=T) # # drat graph of standard normal # plot(xx,dnorm(xx,0,1),xlim=c(-4,4),ylim=c(0,0.5),type="l",xlab="",ylab="") num.sample<-7 s<-rep(0,num.rep) for (i in 1:num.sample){ s<-s+runif(num.rep,0,1)/num.sample } par(new=T) # # # drat graph of centered sample mean # plot(density(sqrt(12*num.sample)*(s-1/2)),xlim=c(-4,4),ylim=c(0,0.5),type="l",xlab="",ylab="")