skxray.core.bin_edges

skxray.core.bin_edges(range_min=None, range_max=None, nbins=None, step=None)

Generate bin edges. The last value is the returned array is the right edge of the last bin, the rest of the values are the left edges of each bin.

If range_max is specified all bin edges will be less than or equal to it’s value.

If range_min is specified all bin edges will be greater than or equal to it’s value

If nbins is specified then there will be than number of bins and the returned array will have length nbins + 1 (as the right most edge is included)

If step is specified then bin width is approximately step (It is not exact due to the nature of floats). The arrays generated by np.cumsum(np.ones(nbins) * step) and np.arange(nbins) * step are not identical. This function uses the second method in all cases where step is specified.

Warning

If the set (range_min, range_max, step) is given there is no guarantee that range_max - range_min is an integer multiple of step. In this case the left most bin edge is range_min and the right most bin edge is less than range_max and the distance between the right most edge and range_max is not greater than step (this is the same behavior as the built-in range()). It is not recommended to specify bins in this manner.

Parameters:

range_min : float, optional

The minimum value that may be included as a bin edge

range_max : float, optional

The maximum value that may be included as a bin edge

nbins : int, optional

The number of bins, if specified the length of the returned value will be nbins + 1

step : float, optional

The step between the bins

Returns:

np.array :

An array of floats for the bin edges. The last value is the right edge of the last bin.