Skip to main content

Module least_squares

Module least_squares 

Source
Expand description

Nonlinear least squares by the Levenberg-Marquardt method, and curve fitting built on it.

The problem is min_p F(p) = ½ Σ r_i(p)² for a residual vector r: ℝⁿ → ℝᵐ (m ≥ n). Each iteration solves the damped Gauss-Newton system (JᵀJ + μ D) h = −Jᵀr, where D is the diagonal of JᵀJ (Marquardt’s scaling, which makes the method invariant to rescaling the parameters). The damping μ follows Nielsen’s gain-ratio update: steps that achieve the predicted reduction shrink μ towards Gauss-Newton, failed steps grow it towards a short gradient-descent step.

See the book entry Nonlinear least squares and curve fitting.

Structs§

CurveFitResult
The outcome of curve_fit.
LeastSquaresResult
The outcome of a least-squares solve.
LevenbergMarquardt
Levenberg-Marquardt solver. The tolerance (default 1e-10) applies to the gradient infinity norm (scaled by 1e-2), the relative step size and the relative cost reduction; bounds, when set, are enforced by projecting each trial point onto the box.

Functions§

curve_fit
Fits model(x, p) to data (x_i, y_i) by weighted least squares with Levenberg-Marquardt.