pysolvegn.scale_rho_function#
- scale_rho_function(rho_func, loss_scale)[source]#
Wrap any loss function \(\rho\) (predefined or custom) into its scaled version \(\rho_C\) with the soft threshold \(C\) (
loss_scale):\[\rho_C(x) = C^2 \rho\left(\frac{x}{C^2}\right)\]\[\rho_C'(x) = \rho'\left(\frac{x}{C^2}\right) \qquad \rho_C''(x) = \frac{1}{C^2} \rho''\left(\frac{x}{C^2}\right)\]\(C\) is the residual value separating the inliers from the outliers, expressed in the unit of the residuals (same as
f_scaleinscipy.optimize.least_squares). For small residuals (\(|r| \ll C\)), \(\rho_C(r^2) \approx r^2\) whatever \(C\). The linear loss is invariant: \(\rho_C(x) = x\).- Parameters:
rho_func (Callable) – The loss function taking the squared residuals and returning \((\rho, \rho', \rho'')\).
loss_scale (Real) – The soft threshold \(C\). Must be finite and strictly positive.
- Returns:
The scaled loss function with the same signature. If
loss_scale == 1,rho_funcis returned unchanged.- Return type:
Callable