如何规范化scipy中指数分布的直方图?

2024-10-01 09:25:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用指数分布来拟合数据集。奇怪的是,无论我做什么,我似乎都无法缩放直方图,使之适合指数分布。在

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

Probability distribution. Note how the histogram has much more area than the exponential fit.

由于某种原因,直方图占用的空间比概率分布要大得多,尽管我赋范了=1。我能做些什么使事情更合适吗?在


Tags: 数据normdatapdfparamplot直方图loc
1条回答
网友
1楼 · 发布于 2024-10-01 09:25:10

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

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

正确绘制时,数据看起来不错:

enter image description here

相关问题 更多 >