因为hist的规范化选项返回点的密度,例如dN / dx
您需要的是这样的:
# assuming that mydata is an numpy array ax.hist(mydata, weights=np.zeros_like(mydata) + 1. / mydata.size) # this will give you fractions

因为hist的规范化选项返回点的密度,例如dN / dx
您需要的是这样的:
# assuming that mydata is an numpy array ax.hist(mydata, weights=np.zeros_like(mydata) + 1. / mydata.size) # this will give you fractions