Module iaf.stats
Statistics functionalities.
Functions
def hist_bins(values: numpy.ndarray, bin_size: float) ‑> tuple-
Return the bins to be used for the passed values and bin size.
Parameters
values:np.ndarray- One-dimensional array of values for which to determine the ideal histogram bins.
bin_size:float- Bin size to use.
Returns
bin_edges:np.ndarray- Array of bin edges (to use with np.histogram()).
bin_centers:np.ndarray- Array of bin centers.
bin_width:- Bin width.
def ideal_hist_bins(values: numpy.ndarray, scott: bool = False)-
Calculate the ideal histogram bins using the Freedman-Diaconis rule.
See: https://en.wikipedia.org/wiki/Freedman%E2%80%93Diaconis_rule
Parameters
values:np.ndarray- One-dimensional array of values for which to determine the ideal histogram bins.
scott:bool- Whether to use Scott's normal reference rule (if the data is normally distributed).
Returns
bin_edges:np.ndarray- Array of bin edges (to use with np.histogram()).
bin_centers:np.ndarray- Array of bin centers.
bin_size:- Bin width.
def prepare_histogram(values: numpy.ndarray, normalize: bool = True, auto_bins: bool = True, scott: bool = False, bin_size: float = 0.0)-
Return histogram counts and bins for given values with provided or automatically calculated bin number.
Parameters
values:np.ndarray- Array of values. It may contain NaNs.
normalize:bool- Whether to normalize the histogram to a probability mass function (PMF). The integral of the PMF is 1.0.
auto_bins:bool- Whether to automatically calculate the bin size from the data.
scott:bool- Whether to use Scott's normal reference rule (the data should be normally distributed). This is used only
if
auto_binsis True. bin_size:float- Bin size to use if
auto_binsis False. It will be ignored ifauto_binsis True.
Returns
n:np.ndarray- Histogram counts (optionally normalized to sum to 1.0).
bin_edges:np.ndarray- Array of bin edges (to use with np.histogram()).
bin_centers:np.ndarray- Array of bin centers.
bin_width:- Bin width.