np.bincount介绍

假设给定的数值中,最大数是max,

那么np.bincount 统计的就是0~ max之间,每个数出现的次数;

从而,
bin的个数 = 给定的数值中,最大的数 + 1;

0~ max 之间的个数 = max + 1 = bin 个数

举例

给定的x中最大的数为7,因此bin的数量为8;

x = np.array([0, 1, 1, 3, 2, 1, 7])

那么np.count() , 统计的便是从 0 到 7总共这8 个数, 每个数出现的次数;

np.bincount(x)
输出: array([1, 3, 1, 1, 0, 0, 0, 1])

猜你喜欢

转载自blog.csdn.net/chumingqian/article/details/129648429
np