# RE: [R] Using R to illustrate the Central Limit Theorem

From: Francisco J. Zagmutt <gerifalte28_at_hotmail.com>
Date: Fri 22 Apr 2005 - 03:34:28 EST

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@gmail.com>
>To: r-help@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.
>
>
>Paul
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help