【发布时间】:2017-10-30 11:47:36
【问题描述】:
我在使用 Python 直方图时遇到了一些问题。我有 2 条贝尔曲线,它们的点数相同,但这些点的值却大不相同。我想比较曲线的形状。图 1 和图 2 显示了我得到的结果。我希望它看起来像下面的情节 3,但不是有点!
import numpy as np
import matplotlib.pyplot as plt
hist1 = np.random.normal(0,100,1000)
hist2 = np.random.normal(0,1,1000)
nBins = 100
plt.figure(1)
plt.hist((hist1,hist2),bins=nBins)
plt.figure(2)
plt.hist(hist1,bins=nBins)
plt.hist(hist2,bins=nBins)
plt.figure(3)
plt.plot(np.histogram(hist1,bins=nBins)[0],'o')
plt.plot(np.histogram(hist2,bins=nBins)[0],'o')
【问题讨论】:
-
你不能只是去比较它们。一种策略是将它们都标准化为 mu=0 sigma=1 的高斯分布。也许这也可以帮助您比较分布docs.scipy.org/doc/scipy-0.19.1/reference/generated/… 这是一种更“花哨”的比较方式,而不是使用视觉效果。但最终它基本上也使用标准法线。虽然它可以选择放置两个不同的分布进行比较,这对你来说可能很有趣。
-
谢谢,伊格纳西奥。我不知道这个 zmap!
-
我也没有,正在寻找如何标准化数组并发现并认为它可能很有趣。
标签: python matplotlib histogram