> 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... >
numpy.bincount? Docstring: bincount(x,weights=None) 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. -JJ _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion