pub fn shrink_to_psd(r: &[f64]) -> Result<Vec<f64>>Expand description
Shrinking repair for a possibly non-PSD autocovariance sequence
(Rousseeuw & Molenberghs 1993): return r' with r'(0) = r(0) and
r'(h) = (1−λ) r(h), λ the smallest value in [0, 1] (up to bisection
tolerance) such that the Toeplitz matrix of r' stays positive definite
with a relative ridge margin of 1e-3 · r(0) — the margin keeps estimated
sequences away from the PD boundary, where Levinson would report spurious
reflection coefficients near ±1. On a sequence that already satisfies the
margin this returns the input unchanged (λ = 0).