popmon.stats package
Submodules
popmon.stats.numpy module
- popmon.stats.numpy.covariance_multinomial_probability_distribution(entries)
Calculate covariance matrix of a single multinomial probability distribution
- Parameters
entries – entries of input histogram
- Returns
numpy 2D array with covariance matrix of multinomial probability distribution
- popmon.stats.numpy.mad(a, c=0.6745, axis=0)
Median Absolute Deviation along given axis of an array
mad = median(abs(a - median(a)))/c
Copyright statsmodels: Kindly taken from statsmodels package and then modified to work with dataframes as well. Reference: https://www.statsmodels.org/dev/_modules/statsmodels/robust/scale.html#mad License: https://github.com/statsmodels/statsmodels/blob/master/LICENSE.txt All modifications copyright ING WBAA.
- Parameters
a – array_like Input array.
c (float) – optional. The normalization constant. Defined as scipy.stats.norm.ppf(3/4.), which is approximately .6745.
axis (int) – optional. The default is 0. Can also be None.
center – callable or float. If a callable is provided, such as the default np.median then it is expected to be called center(a). The axis argument will be applied via np.apply_over_axes. Otherwise, provide a float.
- Returns
mad
- Return type
float
- popmon.stats.numpy.mean(a, weights=None, axis=None, dtype=None, keepdims=False, ddof=0)
Compute the weighted mean along the specified axis.
- Parameters
a – Array containing numbers whose mean is desired. If a is not an array, a conversion is attempted.
weights – Array containing weights for the elements of a. If weights is not an array, a conversion is attempted.
axis – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array. Type is None or int or tuple of ints, optional.
dtype – data type to use in computing the mean.
keepdims (bool) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.
ddof (int) – delta degrees of freedom
- Returns
np.ndarray
- popmon.stats.numpy.median(a, weights=None, axis=None, keepdims=False)
Compute the weighted median along the specified axis.
After https://en.wikipedia.org/wiki/Percentile#Weighted_percentile
- Parameters
a – Array containing numbers whose median is desired. If a is not an array, a conversion is attempted.
weights – Array containing weights for the elements of a. If weights is not an array, a conversion is attempted.
axis – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array. Type is None or int or tuple of ints, optional.
keepdims (bool) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.
- Returns
number or array
- popmon.stats.numpy.probability_distribution_mean_covariance(entries_list)
Mean normalized histogram and covariance of list of input histograms
- Parameters
entries_list – numpy 2D array shape (n_histos, n_bins,) with bin counts of histograms
- Returns
mean normalized histogram, covariance probability matrix
- popmon.stats.numpy.quantile(a, q, weights=None, axis=None, keepdims=False)
Compute the weighted quantiles along the specified axis
After https://en.wikipedia.org/wiki/Percentile#Weighted_percentile
If q is a single quantile and axis=None, then the result is a scalar. If multiple quantiles are given, first axis of the result corresponds to the quantiles. The other axes are the axes that remain after the reduction of a.
- Parameters
a – Array containing numbers whose median is desired. If a is not an array, a conversion is attempted
q – Quantile or sequence of quantiles to compute, which must be between 0 and 1 inclusive
weights – Array containing weights for the elements of a. If weights is not an array, a conversion is attempted.
axis – Axis or axes along which the quantiles are computed. The default is to compute the quantile(s) along a flattened. Type is int, tuple of int, None, optional. version of the array
keepdims (bool) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.
- Returns
scalar or ndarray
- popmon.stats.numpy.std(a, weights=None, axis=None, dtype=None, ddof=0, keepdims=False)
Compute the weighted standard deviation along the specified axis.
- Parameters
a – Array containing numbers whose standard deviation is desired. If a is not an array, a conversion is attempted.
weights – Array containing weights for the elements of a. If weights is not an array, a conversion is attempted.
axis – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array. Type is None or int or tuple of ints, optional.
dtype – data type to use in computing the mean.
ddof (int) – Delta Degrees of Freedom. The divisor used in calculations is
W - ddof
, whereW
is the sum of weights (or number of elements if weights is None). By default ddof is zerokeepdims (bool) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.
- Returns
np.ndarray