hmean(a, axis=0, dtype=None, *, weights=None, nan_policy='propagate', keepdims=False)
The weighted harmonic mean of the array a_i associated to weights w_i is:
and, with equal weights, it gives:
The harmonic mean is computed over a single dimension of the input array, axis=0 by default, or all values in the array if axis=None. float64 intermediate and return values are used for integer inputs.
Beginning in SciPy 1.9, np.matrix
inputs (not recommended for new code) are converted to np.ndarray
before the calculation is performed. In this case, the output will be a scalar or np.ndarray
of appropriate shape rather than a 2D np.matrix
. Similarly, while masked elements of masked arrays are ignored, the output will be a scalar or np.ndarray
rather than a masked array with mask=False
.
Input array, masked array or object that can be converted to an array.
If an int, the axis of the input along which to compute the statistic. The statistic of each axis-slice (e.g. row) of the input will appear in a corresponding element of the output. If None
, the input will be raveled before computing the statistic.
Defines how to handle input NaNs.
propagate
: if a NaN is present in the axis slice (e.g. row) along which the statistic is computed, the corresponding entry of the output will be NaN.omit
: NaNs will be omitted when performing the calculation. If insufficient data remains in the axis slice along which the statistic is computed, the corresponding entry of the output will be NaN.raise
: if a NaN is present, a ValueError
will be raised.If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
Calculate the weighted harmonic mean along the specified axis.
gmean
numpy.average
numpy.mean
from scipy.stats import hmean
hmean([1, 4])
hmean([1, 2, 3, 4, 5, 6, 7])
hmean([1, 4, 7], weights=[3, 1, 3])
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.stats._stats_py:pmean
scipy.stats._stats_py:gmean
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them