Skip to content
Prev 77842 / 398502 Next

hist(x, ...) with normal distribution curve

Hi

answered hundered times.
x<-rnorm(150) 
h<-hist(x,breaks=15) 
xhist<-c(min(h$breaks),h$breaks) 
yhist<-c(0,h$density,0) 
xfit<-seq(min(x),max(x),length=40) 
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x)) 
plot(xhist,yhist,type="s",ylim=c(0,max(yhist,yfit))) 
lines(xfit,yfit) 


Bill 

above is e.g. Bill Simpson's answer from 2001. Found from R-site 
search  ***histogram density normal***.

HTH
Petr
On 25 Sep 2005 at 14:34, Knut Krueger wrote:

            
Petr Pikal
petr.pikal at precheza.cz