10.07.2015 Views

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Using</strong> R <strong>for</strong> introductory statistics 176To see that the sampling distribution is not a normal distribution, per<strong>for</strong>m a simulation<strong>for</strong> n=3, 10, 25, 50, and 100. Compare normality with a q-q plot. For n=3 this is done asfollows:> n = 3; m = 200;> res = c()> <strong>for</strong>(i in 1:m) {+ x = rnorm(n) # mu = 0, sigma = 1+ res[i] = (mean(x)−0)/ (sd(x)/sqrt(n))+}> qqnorm(res)For which values of n is the sampling distribution long tailed? For which values is itapproximately normal?6.10 In the previous exercise it is seen that <strong>for</strong> a normal population the samplingdistribution ofis not the normal distribution. Rather, it is the t-distribution with n−1 degrees of freedom.Investigate this with a q-q plot using a random sample from the t-distribution to comparewith the simulation of T. For n=3 this is done as follows:> n=3; m=1000;> res=c()> <strong>for</strong>(i in 1:m) {+ x=rnorm(n) # mu=0, sigma=1+ res[i]=(mean(x)−0)/ (sd(x)/sqrt(n))+}> qqplot(res,rt(m, df=n−1))Verify this graphically <strong>for</strong> n=3, 10, 25, 50, and 100.6.11 In the previous exercise, the sampling distribution ofwas seen to be the t-distribution when the sample comes from a normally distributedpopulation. What about other populations? Repeat the above with the following threemean-zero distributions: the t-distribution with 15 degrees of freedom (symmetric,longish tails), the t-distribution with 2 degrees of freedom (symmetric with long tails),and exponential with rate 1 minus 1 (rexp(10) −1), which is skewed right with mean 0.Do all three populations result in T having an approximate t-distribution? Do any?6.12 We can use probability to estimate a value of π. How? The idea dates to 1777 andGeorges Buffon. Pick a point at random from a square of side length 2 centered at theorigin. Inside the square draw a circle of radius 1. The probability that the point is insidethe circle is equal to the area of the circle divided by the area of the square:(π·1 2 )/(2 2 )=π/4. We can simulate the probability and then multiply by 4 to estimate π.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!