kinextract.robust_sigma

kinextract.robust_sigma(values: ndarray) float[source]

Robust standard-deviation estimate via the normalized MAD.

Used throughout kinextract wherever a noise scale is needed but the sample may contain outliers (e.g. sigma-clipping continuum residuals or LOSVD-fit residuals) that would bias an ordinary np.std.

Parameters:

values (ndarray) – Sample of residuals or values to estimate the scatter of. Non-finite entries are dropped before the estimate is computed.

Returns:

1.4826 * median(|values - median(values)|), which is a consistent estimator of the standard deviation for Gaussian data. Falls back to np.std if the MAD is exactly zero (e.g. a sample with many repeated values), and returns 0.0 for a single finite value or nan if no finite values remain.

Return type:

float