bin的数量比x中的最大值大1,每个bin给出了它的索引值在x中出现的次数。
代码:
x = np.array([0, 1, 1, 3, 2, 1, 7])
np.bincount(x)
# array([1, 3, 1, 1, 0, 0, 0, 1])
解释:
- bin的数量比x中的最大值大1,即7+1=8, 有8个bin
- 对于bin=0, x中0出现了1次,对于bin=1, x中出现了3次,对于bin=2, x中出现了0次.....
bin的数量比x中的最大值大1,每个bin给出了它的索引值在x中出现的次数。
代码:
x = np.array([0, 1, 1, 3, 2, 1, 7])
np.bincount(x)
# array([1, 3, 1, 1, 0, 0, 0, 1])
解释: