pyhctsa.robust.bf_hist_edges

pyhctsa.robust.bf_hist_edges(y, bin_rule='auto', limits=None)

Equal-width histogram bin edges from an explicit bin-count rule (hctsa BF_HistEdges).

The bins span [min(y), max(y)] (or limits) with width (max - min)/num_bins. The interior edges are lowered, and the end edges widened, by 1e-6 of a bin width, so that values exactly on an edge of the ideal grid (lattice-valued data) always fall just above it, in the upper bin. Pass the result to np.histogram / np.searchsorted (right-open bins).

Spreads at the level of rounding are treated as zero: data whose range is at most 1e-12 of their largest magnitude are treated as constant (one bin), and an IQR at most 1e-12 of the largest magnitude counts as zero in the rules. Values that are mathematically equal but computed by different arithmetic (e.g., distances between points of a lattice-valued series) differ in their last bits, and would otherwise set the number of bins, or the bins themselves, by round-off.

Parameters:
y : array-like

The data (NaNs are ignored).

bin_rule : int or str, optional

The number of bins, or a rule for n values: 'sqrt' (ceil(sqrt(n))), 'sturges' (ceil(log2(n) + 1)), 'fd' (Freedman-Diaconis, ceil(range/(2 IQR n^(-1/3))), Sturges if IQR = 0) or 'auto' (the larger of the two; default). A rule gives at most n and at least 1 bins.

limits : array-like, optional

[lower, upper], the interval to span instead of the range of the data.

Returns:

num_bins + 1 increasing edges.

Return type:

numpy.ndarray