statistics - How to get dnorm curve using R -
x1000 <- rep(na, 1000) n = 10 for(i in 1:1000){ x1000[i] <- mean(rpois(1000, 0.3)) } hist(x1000, freq = f) curve(dnorm(x1000, mean = 0.3, sd = sqrt(0.3)))
i'm trying overlaid curve. however, gives me:
error in curve(dnorm(x1000, mean = 0.3, sd = sqrt(0.3))) : 'expr' must function, or call or expression containing 'x'
you close, asked (technically):
hist(x1000, col="red", freq=f) curve( dnorm(x, mean=.3,sd=sqrt(.3)), col="blue", add=t) # expression containing 'x'
but think really want is:
curve( dnorm(x, mean=mean(x1000),sd=sd(x1000)), col="blue", add=t)
or:
curve( dnorm(x, mean=mean(x1000),sd=sqrt(mean(x1000)/length(x1000)), col="blue", add=t)
Comments
Post a Comment