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§
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.345gives ~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 atscale_floor. - median
- The median of
values, computed on atotal_cmpsort so the order (and thus the result for an even count, which averages the two central values) is deterministic. An empty slice yields0.0. The two central elements use(a + b) / 2.0when its addition is finite, witha / 2.0 + b / 2.0only as the overflow-safe fallback. Neither path uses FMA.