[R] Using R to illustrate the Central Limit Theorem
Francisco J. Zagmutt
gerifalte28 at hotmail.com
Thu Apr 21 19:34:28 CEST 2005
Hi Paul
This is one of many ways to do it
hist(runif(30))#histogram from 30 random samples from a uniform(0,1)
mm=c(NULL)#creates null vector
for(i in 1:100){mm[i]=mean(runif(30))}#100 sample means of 30 samples each
from a uniform(0,1)
hist(mm)#the distribution of the sample mean looks normal!
You can even nest this loop within another loop so your student can see
several histograms showing a "normal" behaviour.
I hope this helps
Francisco
>From: Paul Smith <phhs80 at gmail.com>
>To: r-help at stat.math.ethz.ch
>Subject: [R] Using R to illustrate the Central Limit Theorem
>Date: Thu, 21 Apr 2005 18:06:40 +0100
>
>Dear All
>
>I am totally new to R and I would like to know whether R is able and
>appropriate to illustrate to my students the Central Limit Theorem,
>using for instance 100 independent variables with uniform distribution
>and showing that their sum is a variable with an approximated normal
>distribution.
>
>Thanks in advance,
>
>Paul
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide!
>http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list