[Numpy-discussion] Fast histogram
Thu Apr 17 12:12:36 CDT 2008
> But even if indices = array, one still needs to do something like:
> for index in indices: histogram[index] += 1
> Which is slow in python and fast in C.
> I'm guessing that there's no utility function in numpy that does a
> loop like this? If so, that would be handy, but if now, I think I need
> to dig out the numpy book and write a little extension...
Return the number of occurrences of each value in x.
x must be a list of non-negative integers. The output, b[i],
represents the number of times that i is found in x. If weights
is specified, every occurrence of i at a position p contributes
weights[p] instead of 1.
See also: histogram, digitize, unique.
More information about the Numpy-discussion