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' 

enter image description here

but think really want is:

curve( dnorm(x, mean=mean(x1000),sd=sd(x1000)), col="blue", add=t) 

enter image description here

or:

curve( dnorm(x, mean=mean(x1000),sd=sqrt(mean(x1000)/length(x1000)), col="blue", add=t) 

enter image description here


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -