Numpy: use bins with infinite range
The function numpy.histogram()
happily accepts infinite values in the bins
argument:
numpy.histogram(my_values, bins=numpy.r_[-numpy.inf, my_bins, numpy.inf])
Alternatively, you could use a combination of numpy.searchsorted()
and numpy.bincount()
, though I don't see much advantage to that approach.
You can specify numpy.inf
as the upper and -numpy.inf
as the lower bin limits.