staircase.hist_from_ecdf

staircase.hist_from_ecdf(ecdf, bin_edges=None, closed='left')

Calculates a histogram from a Stairs instance corresponding to an empirical cumulative distribution function.

Such ecdf stair instances are returned from Stairs.ecdf_stairs(). This function predominantly exists to allow users to store the result of a ecdf stairs instance locally, and experiment with bin_edges without requiring the recalculation of the ecdf.

Parameters:
  • ecdf (Stairs) – lower bound of the step-function domain on which to perform the calculation
  • bin_edges (int, float, optional) – defines the bin edges for the histogram (it is the domain of the ecdf that is being binned). If not specified the bin_edges will be assumed to be the integers which cover the domain of the ecdf
  • closed ({'left', 'right'}, default 'left') – determines whether the bins, which are half-open intervals, are left-closed , or right-closed
Returns:

A Series, with a pandas.IntervalIndex, representing the values of the histogram

Return type:

pandas.Series

Examples

>>> import staircase as sc
>>> s1_ecdf_stairs = s1.ecdf_stairs()
>>> fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8,5), sharey=False, sharex=False)
>>> for ax, title, stair_instance in zip(axes, ("s1", "s1 ecdf"), (s1, s1_ecdf_stairs)):
...     stair_instance.plot(ax)
...     ax.set_title(title)
>>> plt.show()
../_images/staircase-hist_from_ecdf-1_00_00.png
>>> sc.hist_from_ecdf(s1_ecdf_stairs)
[-1, 0)    0.25
[0, 1)     0.25
[1, 2)     0.50
dtype: float64
>>> sc.hist_from_ecdf(s1_ecdf_stairs, bin_edges=(-1,1,3))
[-1, 1)    0.5
[1, 3)     0.5
dtype: float64