Adding a best fit normal on top of a histogram in

2019-09-07 02:09发布

Possible Duplicate:
Fitting a density curve to a histogram in R

I'm trying to add a best fit normal over a histogram in R. Right now, I have the following:

x<-table[table$position==1,]$rt
hist(x,breaks=length(x))

And now I'd like to plot a normal curve over this plot which allows for skew and for kurtosis. How can I do this? This is what my curve looks like:

enter image description here

标签: r plot histogram
1条回答
混吃等死
2楼-- · 2019-09-07 03:07

I would suggest not using the terms "skew" and "kurtosis" in the same sentence with "Normal curve", since Normal curves have neither. Perhaps you are looking for one or two parameter continuous density distribution that might be comparable to a function that was bounded at zero and had right skewing? If so then you should think about a) posting the data, b) consider plotting a Poisson, a log-Normal, or a gamma density on top of a histogram.

set.seed(123)
xpois <- trunc(rpois(100, 4))
hist(xpois)
lines(seq(0,10), 100*dpois(seq(0,10), 4))

enter image description here

查看更多
登录 后发表回答