I have a Numpy array and a list of indices whose values I would like to increment by one. This list may contain repeated indices, and I would like the increment to scale wit
If b is a small subrange of a, one can refine Alok's answer like this:
b
a
import numpy as np a = np.zeros( 100000, int ) b = np.array( [99999, 99997, 99999] ) blo, bhi = b.min(), b.max() bbins = np.bincount( b - blo ) a[blo:bhi+1] += bbins print a[blo:bhi+1] # 1 0 2