# lab4 solutions - for (i in 1:500) { means[i] &amp;amp;lt;-...

This preview shows pages 1–2. Sign up to view the full content.

# lab4 # 1. x <- rnorm(2) mean(x) mean(rnorm(2)) mean(rnorm(2)) mean(rnorm(2)) ## the means tend to be close to 0, but they can sometimes differ more than a little from 0. # 2. means <- c() for (i in 1:500) { means[i] <- mean(rnorm(2)) } hist(means) # 3. means <- c() for (i in 1:500) { means[i] <- mean(rnorm(10)) } hist(means) # 4. means <- c() for (i in 1:500) { means[i] <- mean(rnorm(17)) } hist(means) means <- c() for (i in 1:500) { means[i] <- mean(rnorm(25)) } hist(means) means <- c() for (i in 1:500) { means[i] <- mean(rnorm(50)) } hist(means) means <- c() for (i in 1:500) { means[i] <- mean(rnorm(100)) } hist(means) # 4. (ahem, again). means <- c()

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for (i in 1:500) { means[i] &lt;- mean(runif(2)) } plot(0,0,type=&quot;n&quot;, xlim=c(0,1), ylim=c(0,10), xlab=&quot;density estimate&quot;, ylab=&quot;f(x)&quot;) lines(density(means)) means &lt;- c() for (i in 1:500) { means[i] &lt;- mean(runif(10)) } lines(density(means)) means &lt;- c() for (i in 1:500) { means[i] &lt;- mean(runif(17)) } lines(density(means)) means &lt;- c() for (i in 1:500) { means[i] &lt;- mean(runif(25)) } lines(density(means)) means &lt;- c() for (i in 1:500) { means[i] &lt;- mean(runif(50)) } lines(density(means)) means &lt;- c() for (i in 1:500) { means[i] &lt;- mean(runif(100)) } lines(density(means))...
View Full Document

## This note was uploaded on 04/27/2009 for the course STAT 200 taught by Professor Agniel during the Spring '09 term at University of Illinois at Urbana–Champaign.

### Page1 / 2

lab4 solutions - for (i in 1:500) { means[i] &amp;amp;lt;-...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online