Which histogram bin receives a value on an edge?
histogram counts observations in bins. Each bin includes its left edge, and only the last bin also includes its right edge.
numpy.histogram in practice
With edges zero, one and two, readings one and two both enter the second bin. Values outside the specified overall range do not contribute to these bins.
import numpy as np
np.histogram([0,1,2,4],bins=[0,1,2])[0]Result [1, 2]
中文
恰在直方图区间边界上的值算入哪一格?
histogram 对每个区间计数。除最后一格外,区间左闭右开,最后一格包含右端点。
numpy.histogram 算例
边界为 0、1、2 时,读数 1 和 2 均落入第二格。落在给定整体范围以外的读数不会计入这些桶。
import numpy as np
np.histogram([0,1,2,4],bins=[0,1,2])[0]结果 [1, 2]