如何对科学中的指数分布的直方图进行归一化? [英] How to normalize a histogram of an exponential distributionin scipy?

查看:368
本文介绍了如何对科学中的指数分布的直方图进行归一化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将指数分布拟合到我拥有的数据集中。奇怪的是,无论我做什么,我似乎都无法缩放直方图,因此它不适合拟合的指数分布。

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

< img src = https://i.stack.imgur.com/bna8O.png alt =概率分布。请注意直方图的面积比指数拟合大得多。>

由于某种原因,即使我将normed = 1,直方图所占的空间也比概率分布大得多。我可以做些什么使事情变得更合适吗?

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?

推荐答案

您犯了一个错误。您拟合了指数,但绘制了正态分布:

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:

这篇关于如何对科学中的指数分布的直方图进行归一化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆