Skip to main content

Module robust

Module robust 

Source
Expand description

Robust M-estimation primitives for iteratively reweighted least squares.

These are the per-outer-iteration reweighting pieces of a Huber IRLS loop: a median-absolute-deviation scale estimate and the Huber weight function. They are deliberately pure f64 arithmetic (abs, compare, divide, sort by f64::total_cmp) with no fused-multiply-add and no contraction, so the per-iteration weight vector is bit-reproducible against an explicit outer-loop reference recipe. The trust-region linear-algebra step that consumes the weights is BLAS-bound and is NOT a 0-ULP target.

Enums§

RobustError

Constants§

HUBER_K
The default Huber tuning constant. Residuals scaled below this (in units of the robust scale) keep full weight; larger ones are down-weighted as k / |u|. 1.345 gives ~95% efficiency at the Gaussian model.
MAD_NORMAL_CONST
The MAD-to-sigma consistency constant for a normal distribution, 1 / Phi^-1(3/4). Multiplying the median absolute deviation by this makes it a consistent estimator of the standard deviation under normality.

Functions§

huber_weight
The Huber weight for a scaled residual u = r / s.
mad_scale
The median-absolute-deviation scale of residuals, scaled to a normal-sigma estimate and floored at scale_floor.
median
The median of values, computed on a total_cmp sort so the order (and thus the result for an even count, which averages the two central values) is deterministic. An empty slice yields 0.0. The averaging of the two central elements is a single (a + b) / 2.0, no FMA.