pylab.hist(数据,规范= 1).标准化似乎工作不正确 [英] pylab.hist(data, normed=1). Normalization seems to work incorrect
本文介绍了pylab.hist(数据,规范= 1).标准化似乎工作不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用参数 normed=1 创建直方图
I'm trying to create a histogram with argument normed=1
例如:
import pylab
data = ([1,1,2,3,3,3,3,3,4,5.1])
pylab.hist(data, normed=1)
pylab.show()
我预计 bin 的总和为 1.但是,其中一个 bin 比 1 大.这个归一化做了什么?以及如何创建具有这种归一化的直方图,使得直方图的积分等于 1?
I expected that the sum of the bins would be 1. But instead, one of the bin is bigger then 1. What this normalization did? And how to create a histogram with such normalization that the integral of the histogram would be equal 1?
推荐答案
有关如何使直方图中所有 bin 的总和等于 1 的信息,请参阅我的另一篇文章:https://stackoverflow.com/a/16399202/1542814
See my other post for how to make the sum of all bins in a histogram equal to one: https://stackoverflow.com/a/16399202/1542814
复制&粘贴:
weights = np.ones_like(myarray)/float(len(myarray))
plt.hist(myarray, weights=weights)
其中 myarray 包含您的数据
where myarray contains your data
这篇关于pylab.hist(数据,规范= 1).标准化似乎工作不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文