1>>> np.bincount(np.arange(5))
2array([1, 1, 1, 1, 1])
3>>> np.bincount(np.array([0, 1, 1, 3, 2, 1, 7]))
4array([1, 3, 1, 1, 0, 0, 0, 1])
5
1>>> w = np.array([0.3, 0.5, 0.2, 0.7, 1., -0.6]) # weights
2>>> x = np.array([0, 1, 1, 2, 2, 2])
3>>> np.bincount(x, weights=w)
4array([ 0.3, 0.7, 1.1])
5