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

From: Francisco J. Zagmutt <>
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


>From: Paul Smith <>
>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
>Thanks in advance,
> mailing list
>PLEASE do read the posting guide!
> mailing list PLEASE do read the posting guide! Received on Fri Apr 22 03:38:35 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:21 EST