pysolvegn.huber_rho#
- huber_rho(x)[source]#
Compute the Huber robust cost function and its derivatives (same definition as
scipy.optimize.least_squares).\[\begin{split}\rho(x) = \begin{cases} x & \text{if } x \leq 1 \\ 2\sqrt{x} - 1 & \text{otherwise} \end{cases}\end{split}\]\[\begin{split}\rho'(x) = \begin{cases} 1 & \text{if } x \leq 1 \\ x^{-1/2} & \text{otherwise} \end{cases}\end{split}\]\[\begin{split}\rho''(x) = \begin{cases} 0 & \text{if } x \leq 1 \\ -\frac{1}{2} x^{-3/2} & \text{otherwise} \end{cases}\end{split}\]Quadratic for the small residuals (\(|r| \leq 1\)) and linear for the large ones. The loss is convex: \(\rho' + 2 \rho'' x \geq 0\) everywhere (equal to
0beyond the threshold, where the IRLS fallback of_build_tilde_R_and_tilde_J()applies).- Parameters:
x (ArrayLike) – Squared residuals \(x = \|R\|^2\). Shape
(N,).- Returns:
rho (numpy.ndarray) – The cost function values with shape
(N,).rho_prime (numpy.ndarray) – The first derivatives with shape
(N,).rho_double_prime (numpy.ndarray) – The second derivatives with shape
(N,).
- Return type:
Tuple[ndarray, ndarray, ndarray]