[SciPy-user] More elegant solution for binning lookup?
Stefan van der Walt
Sun Feb 18 17:21:13 CST 2007
On Sun, Feb 18, 2007 at 05:22:08PM -0500, Tom Bridgman wrote:
> I've got an array of samples through a region and a value 'R' where I
> want to find the proper bin in 'radius'. 'R' will generally not
> match any value in 'radius'.
Would digitize do the job?
Return the index of the bin to which each value of x belongs.
Each index i returned is such that bins[i-1] <= x < bins[i] if
bins is monotonically increasing, or bins [i-1] > x >= bins[i] if
bins is monotonically decreasing.
Beyond the bounds of the bins 0 or len(bins) is returned as appropriate.
More information about the SciPy-user