bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / stats / _stats_py / sigmaclip
function
scipy.stats._stats_py:sigmaclip
source: build-install/usr/lib/python3.14/site-packages/scipy/stats/_stats_py.py:3389
Signature
def sigmaclip(a, low = 4.0, high = 4.0, *, nan_policy = propagate)Summary
Perform iterative sigma-clipping of array elements.
Extended Summary
Starting from the full sample, all elements outside the critical range are removed, i.e. all elements of the input array c that satisfy either of the following conditions
c < mean(c) - std(c)*low c > mean(c) + std(c)*high
The iteration continues with the updated sample until no elements are outside the (updated) range.
Parameters
a: array_likeData array, will be raveled if not 1-D.
low: float, optionalLower bound factor of sigma clipping. Default is 4.
high: float, optionalUpper bound factor of sigma clipping. Default is 4.
nan_policy: {'propagate', 'omit', 'raise'}Defines how to handle input NaNs.
propagate: if a NaN is present in the input, the clipped array will be empty, and the upper and lower thresholds will be NaN.omit: NaNs will be omitted when performing the calculation.raise: if a NaN is present, aValueErrorwill be raised.
Returns
clipped: ndarrayInput array with clipped elements removed.
lower: floatLower threshold value use for clipping.
upper: floatUpper threshold value use for clipping.
Notes
This function iteratively removes observations. Once observations are removed, they are not re-added in subsequent iterations. Consequently, although it is often the case that clipped is identical to a[(a >= lower) & (a <= upper)], this property is not guaranteed to be satisfied; clipped may have fewer elements.
Examples
import numpy as np from scipy.stats import sigmaclip a = np.concatenate((np.linspace(9.5, 10.5, 31), np.linspace(0, 20, 5))) fact = 1.5 c, low, upp = sigmaclip(a, fact, fact)✓
c c.var(), c.std() low, c.mean() - fact*c.std(), c.min() upp, c.mean() + fact*c.std(), c.max()✗
(np.float64(10.035355339059327), np.float64(10.035355339059327), np.float64(10.033333333333333))
a = np.concatenate((np.linspace(9.5, 10.5, 11), np.linspace(-100, -50, 3))) c, low, upp = sigmaclip(a, 1.8, 1.8)✓
(c == np.linspace(9.5, 10.5, 11)).all()
✗np.True_
Aliases
scipy.stats.sigmaclip