Adding a best fit normal on top of a histogram in R [duplicate]

a 夏天 提交于 2019-12-12 02:26:01

问题


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:


回答1:


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))



来源:https://stackoverflow.com/questions/7605191/adding-a-best-fit-normal-on-top-of-a-histogram-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!