[Numpy-discussion] finding range of values below threshold in sorted array

Mark Bakker markbak@gmail....
Fri Aug 14 07:27:23 CDT 2009


Hello List,
I am trying to find a quick way to do the following:

I have a *sorted* array of real numbers, say array A, sorted in ascending
order (but easy to store descending if that would help)

I want to find all numbers below a certain value, say b

Sure, I can do

A < b

and I will get back a list with a bunch of True-s and then a bunch of
False's,

but all I need is the highest index for which A[i] < b, since A is sorted.

Does anybody know a quick way to do this? I need to do it a lot, so the
quicker the better.

Thanks,

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090814/35b5023b/attachment-0001.html 


More information about the NumPy-Discussion mailing list