How to normalize a histogram of an exponential distributionin scipy?

Deadly 提交于 2019-12-24 08:24:13

问题


I'm trying to fit an exponential distribution to a dataset I have. Strangely, no matter what I do I can't seem to scale the histogram so it fits the fitted exponential distribution.

param=expon.fit(data)
pdf_fitted=norm.pdf(x,loc=param[0],scale=param[1])
plot(x,pdf_fitted,'r-')
hist(constraint1N55, normed=1,alpha=.3,histtype='stepfilled')

For some reason, the histogram takes up much more space than the probability distribution, even though I have normed=1. Is there something I can do to make things fit more appropriately?


回答1:


You made an error. You fitted to an exponential, but plotted a normal distribution:

pdf_fitted=expon.pdf(x,loc=param[0],scale=param[1])

The data looks good when plotted properly:



来源:https://stackoverflow.com/questions/24011209/how-to-normalize-a-histogram-of-an-exponential-distributionin-scipy

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