km3pipe.stats
¶
Statistics.
Module Contents¶
Classes¶
loguniform (low=0.1, high=1, base=10, *args, **kwargs) |
Loguniform Distributon |
rv_kde (data, bw=None, bw_method=None, bw_statsmodels=False, **kde_args) |
Create a scipy.stats.rv_continuous instance from a (gaussian) KDE. |
hist2d (H2D, *args, **kwargs) |
Simple implementation of a 2d histogram. |
Functions¶
mad (v) |
MAD – Median absolute deviation. More robust than standard deviation. |
mad_std (v) |
Robust estimate of standard deviation using the MAD. |
drop_zero_variance (df) |
Remove columns from dataframe with zero variance. |
param_names (scipy_dist) |
Get names of fit parameters from a scipy.rv_* distribution. |
perc (arr, p=95, **kwargs) |
Create symmetric percentiles, with p coverage. |
resample_1d (arr, n_out=None, random_state=None) |
Resample an array, with replacement. |
bootstrap_params (rv_cont, data, n_iter=5, **kwargs) |
Bootstrap the fit params of a distribution. |
param_describe (params, quant=95, axis=0) |
Get mean + quantile range from bootstrapped params. |
bootstrap_fit (rv_cont, data, n_iter=10, quant=95, print_params=True, **kwargs) |
Bootstrap a distribution fit + get confidence intervals for the params. |
bincenters (bins) |
Bincenters, assuming they are all equally spaced. |
-
class
km3pipe.stats.
loguniform
(low=0.1, high=1, base=10, *args, **kwargs)[source]¶ Bases:
scipy.stats.rv_continuous
Loguniform Distributon
-
class
km3pipe.stats.
rv_kde
(data, bw=None, bw_method=None, bw_statsmodels=False, **kde_args)[source]¶ Bases:
scipy.stats.rv_continuous
Create a scipy.stats.rv_continuous instance from a (gaussian) KDE.
Uses the KDE implementation from sklearn.
Automatic bandwidth, either from the statsmodels or scipy implementation.
-
km3pipe.stats.
mad_std
(v)[source]¶ Robust estimate of standard deviation using the MAD.
Lifted from astropy.stats.
-
km3pipe.stats.
param_names
(scipy_dist)[source]¶ Get names of fit parameters from a
scipy.rv_*
distribution.
-
km3pipe.stats.
resample_1d
(arr, n_out=None, random_state=None)[source]¶ Resample an array, with replacement.
Parameters: - arr: np.ndarray
The array is resampled along the first axis.
- n_out: int, optional
Number of samples to return. If not specified, return
len(arr)
samples.
-
km3pipe.stats.
bootstrap_params
(rv_cont, data, n_iter=5, **kwargs)[source]¶ Bootstrap the fit params of a distribution.
Parameters: - rv_cont: scipy.stats.rv_continuous instance
The distribution which to fit.
- data: array-like, 1d
The data on which to fit.
- n_iter: int [default=10]
Number of bootstrap iterations.
-
km3pipe.stats.
param_describe
(params, quant=95, axis=0)[source]¶ Get mean + quantile range from bootstrapped params.
-
km3pipe.stats.
bootstrap_fit
(rv_cont, data, n_iter=10, quant=95, print_params=True, **kwargs)[source]¶ Bootstrap a distribution fit + get confidence intervals for the params.
Parameters: - rv_cont: scipy.stats.rv_continuous instance
The distribution which to fit.
- data: array-like, 1d
The data on which to fit.
- n_iter: int [default=10]
Number of bootstrap iterations.
- quant: int [default=95]
percentile of the confidence limits (default is 95, i.e. 2.5%-97.5%)
- print_params: bool [default=True]
Print a fit summary.