econstatproj1

econstatproj1 - histogram is more like a normal graph,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
F <- function(x){ product = x*(x+1)/2 return(product) } F(10) F(100) F(1000) G <- function(x){ product = x*(x+1)*(2*x+1)/6 return(product) } G(10) G(100) G(1000) sum = 0 for(i in 1:10){ sum = sum + i } sum sum = 0 for(i in 1:100){ sum = sum + i } sum sum = 0 for(i in 1:1000){ sum = sum + i } sum sum = 0 for(i in 1:10){ sum = sum + i*i } sum sum = 0 for(i in 1:100){ sum = sum + i*i } sum sum = 0
Background image of page 1

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

View Full DocumentRight Arrow Icon
for(i in 1:1000){ sum = sum + i*i } sum # f(n) and h(n) are identical except h(n) is in sigma notation, g(n) and l(n) are identical except l(n) is in sigma notation nreps = 1000 nObs= 100 average<-matrix(0, nrow=nreps, ncol=1) for(i in 1:nreps) { sample <- rnorm(nObs, 2, 2) average[i] = mean(sample) } mean(average) var(average) hist(average) # the mean is still close to 2, the variance has shrunk considerably, and the
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: histogram is more like a normal graph, meaning the theoretical prediction is closer with 1000 samples nreps = 1000 nObs= 1000 average<-matrix(0, nrow=nreps, ncol=1) for(i in 1:nreps) { sample <- rnorm(nObs, 2, 2) average[i] = mean(sample) } mean(average) var(average) hist(average) nreps = 1000 nObs= 100 z<-matrix(0, nrow=nreps, ncol=1) for(i in 1:nreps) { sample <- rnorm(nObs, 2, 2) z[i] =sqrt(nObs)*( mean(sample) - 2 )/ 2 } mean(z) var(z) hist(z) nreps = 1000 nObs= 1000 z<-matrix(0, nrow=nreps, ncol=1) for(i in 1:nreps) { sample <- rnorm(nObs, 2, 2) z[i] =sqrt(nObs)*( mean(sample) - 2 )/ 2 } mean(z) var(z) hist(z)...
View Full Document

This note was uploaded on 02/02/2010 for the course MGRL 194 taught by Professor Kirkpatrick during the Spring '08 term at Vanderbilt.

Page1 / 3

econstatproj1 - histogram is more like a normal graph,...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online