<<O>>  Difference Topic R (r1.12 - 17 May 2009 - ChrisJones)

META TOPICPARENT TechStuff
TOC: No TOC in "Home.R"
Line: 191 to 191

Added:
>
>

Testing the central limit theorem

I wanted to test that the mean over a large number of samples can be modeled adequately with a normal distribution.

Further, I wanted to see if the theorem held up when the original distribution was heavily skew.

To investigate:

means<-numeric(10000) //somewhere to store the means

for(i in 1:10000){means[i]<-mean(rbinom(n=10000, prob=.1, size=5))} //generate 10000 random binomial distributions, storing each of their means, note I use prob=.1 producing a heavily skew distribution

h<-hist(means) //plot the distribution

Now lets overlay the idealised normal curve.

x<-seq(0.4766, 0.5262,.0001) //generate the x values, use range(means)

y<-dnorm(x,mean=mean(means),sd(means))*.005*10000 //scale the y values by the bin width and the number of samples (look at the =h= for bin width).
central

Normal approximation looks pretty good.

And the probabilty plot looks like this:

plot(sort(means), qnorm(seq(1/10000, 1,1/10000)))

prob

Again looks very good.


META FILEATTACHMENT multiplot.jpg attr="h" comment="Multi" date="1236370301" path="multiplot.jpg" size="34299" user="ChrisJones" version="1.1"
META FILEATTACHMENT multiplot1.jpg attr="h" comment="another" date="1236370740" path="multiplot1.jpg" size="49539" user="ChrisJones" version="1.1"
META FILEATTACHMENT multiplot4.jpg attr="h" comment="an" date="1236375152" path="multiplot4.jpg" size="66058" user="ChrisJones" version="1.1"
Line: 211 to 248

META FILEATTACHMENT accident2005Legend.jpg attr="h" comment="accident" date="1240054379" path="accident2005Legend.jpg" size="163511" user="ChrisJones" version="1.2"
META FILEATTACHMENT accident2005Lengend.jpg attr="h" comment="accident" date="1240054423" path="accident2005Lengend.jpg" size="28333" user="ChrisJones" version="1.1"
META FILEATTACHMENT accidentHotspot2007.jpg attr="h" comment="blah" date="1240058769" path="~accidentHotspot2007.jpg" size="27318" user="ChrisJones" version="1.1"
Added:
>
>
META FILEATTACHMENT central.jpg attr="h" comment="central" date="1242552167" path="central.jpg" size="19316" user="ChrisJones" version="1.1"
META FILEATTACHMENT probplot.jpg attr="h" comment="prob" date="1242554963" path="probplot.jpg" size="16307" user="ChrisJones" version="1.1"
Revision r1.11 - 18 Apr 2009 - 18:16 - ChrisJones
Revision r1.12 - 17 May 2009 - 09:28 - ChrisJones