Problemcore
Nonlinear least squares
Also called NLLS, nonlinear least squares problem.
Minimize a sum of squared nonlinear residuals of the parameters, the form of bundle adjustment, calibration and most refinement steps in vision.
Nonlinear least squares is the problem of finding the parameters that minimize , where each residual is a smooth but nonlinear function of . It is the standard way to fit a model to data when the model is not linear in its parameters: the residuals are the differences between predicted and measured values. When the measurement errors are independent Gaussian with equal variance, its solution is the maximum likelihood estimate. Unlike the linear least squares problem, it has no closed form, it can have many local minimizers, and it is solved by iteration from a start. The main iterative methods are pages of their own: the Gauss-Newton algorithm linearizes the residuals and solves the normal equations, Levenberg-Marquardt adds damping to keep the cost decreasing, and Powell's dog leg method uses a trust region. In computer vision almost every refinement step has this form, and the largest instance is bundle adjustment, which minimizes the reprojection error over all cameras and points.
In plain words
You have a model with some unknown numbers and many measurements. For each measurement you can compute how far the model is from it. You want the unknown numbers that make the total of the squared distances as small as possible. If the model were a straight line, one formula would give the answer. Here the model bends, for example through an exponential or a rotation, so there is no single formula. You start from a guess and improve it step by step. There can be several "best" spots in different places, and which one you reach depends on where you start.
Definition
Input. A residual function , usually with , that is at least once continuously differentiable. In practice also its Jacobian and a start .
Output. A local minimizer of , or in practice a point where the gradient is small. The global minimizer is wanted but is not guaranteed by any of the standard methods.
Structure. The gradient and the Hessian have a special form:
The first term of the Hessian needs only first derivatives. The second term is small when the residuals are small or nearly linear. All the methods of this group use this fact.
Optimality. At a local minimizer, (the residual is orthogonal to the columns of ) and is positive semidefinite. If and is positive definite, the point is a strict local minimizer.
Residual size. A problem is a zero residual problem if , a small residual problem if the second term of the Hessian is small compared with at , and a large residual problem otherwise. The local rate of Gauss-Newton depends on this class.
Variants
- Weighted. Minimize with a positive definite , the inverse covariance of the measurements. With , replace by to get the plain form.
- Robust. Minimize with an M-estimator that grows slower than the square, such as the Huber function. This is solved by iteratively reweighted least squares.
- Regularized. Add a term for a prior , as in Tikhonov regularization. This is again a least squares problem, with extra residuals.
- On a manifold. Some parameters are rotations or unit vectors. The step is computed in a local parametrization, for example the axis-angle update for a rotation, and the result is mapped back.
- Bound constrained. Simple bounds on , handled by projected or active set versions of the same methods.
- Separable. If some parameters enter linearly, they can be eliminated in closed form (variable projection), which leaves a smaller nonlinear problem.
- Errors in variables. When both the inputs and the outputs of the model are noisy, the residuals are orthogonal distances, and the unknown true inputs become extra parameters. Bundle adjustment and optimal triangulation have this form.
Examples
- Exponential fit. . With at the solution is with zero residual; Gauss-Newton from reaches it to 12 digits in 4 steps (see the Gauss-Newton page).
- The Rosenbrock function. , a zero residual problem with a curved valley. The standard start is , and the minimizer is .
- A one-parameter problem with a nonzero residual. has its minimizer at for , with . Gauss-Newton converges linearly for and does not converge for (Madsen, Nielsen and Tingleff 2004).
- Point triangulation. Find the 3D point that minimizes the reprojection error in two or more images: with 3 parameters.
- Homography refinement. Minimize the transfer error of point matches over the 8 degrees of freedom of a homography, from a linear estimate.
- Camera calibration. Fit the intrinsics, the lens distortion and one pose per image to the observed corners of a target, as in Zhang's method.
- Bundle adjustment. All cameras and all 3D points at once. Here can be in the millions, and the Jacobian is very sparse.
Known algorithms
| method | step | per iteration | local rate | global safeguard |
|---|---|---|---|---|
| Gauss-Newton | solve | quadratic for zero residual, else linear or none | none | |
| Gauss-Newton with a line search | the same, then a backtracking line search | the same plus extra evaluations | as Gauss-Newton | line search |
| Levenberg-Marquardt | solve | per try | as Gauss-Newton when | damping |
| Powell's dog leg | dog leg path in a trust region | per accepted step | as Gauss-Newton near the solution | trust region |
| Newton's method | solve | needs the second derivatives of all | quadratic | needs a line search or trust region |
| Structured quasi-Newton | Gauss-Newton matrix plus an update for the second term | superlinear, also for large residuals | line search | |
| Inexact Newton | solve the Gauss-Newton system by CG | a few products with and | linear to superlinear, by the forcing term | trust region or damping |
The costs are for dense in the real RAM model; a dense factorization is counted as . For bundle adjustment, the reduced camera system, sparse bundle adjustment and inexact Newton bundle adjustment use the sparsity to do much better.
| Algorithm | Time | Space | Properties | Code |
|---|---|---|---|---|
| Gauss-Newton algorithm | Θ(m n^2 + n^3) per_iteration | Θ(m n) extra | deterministicnot globally convergentiterativelocaliterative | 1 language |
| Geiger's method | O(k n) worst · average | O(n) extra | deterministiciterative | 1 language |
| Iteratively regularized Gauss-Newton method | O(k (f + j + m n^2 + n^3)) total | O(m n + n^2) extra | deterministiciterativenot linear in datanot matrix free | 1 language |
| Levenberg-Marquardt algorithm | Θ(m n^2 + n^3) per_iteration | Θ(m n) extra | deterministiciterativelocalmonotoneiterative | 1 language |
| Powell's dog leg method | Θ(m n^2 + n^3) per_iteration | Θ(m n) extra | deterministiciterativelocalmonotoneiterative | 1 language |
Bounds
Global minimization is NP-hard (theorem). Given integers , take the residuals for and . Then exactly when there are signs with , which is the partition problem. So deciding whether the global minimum of a nonlinear least squares problem with quadratic residuals is zero is NP-hard, and no method of this group can promise the global minimizer in polynomial time unless P = NP. The standard methods are local methods.
Statistical accuracy (theorem). If with independent , then the minimizer is the maximum likelihood estimate. When has full column rank at the solution, its covariance is approximately to first order, which matches the Cramer-Rao bound for this model to first order. When is rank deficient, as with a gauge freedom, some directions are not determined by the data at all.
Local rate (theorem). Near a minimizer where has full column rank, Gauss-Newton converges quadratically if the residual is zero, linearly with factor if that norm is below 1, and may not converge otherwise (Dennis and Schnabel, chapter 10; Madsen, Nielsen and Tingleff, section 3.1).
Reductions
- Linear least squares is the case where ; then , the Hessian is exactly, and one Gauss-Newton step solves the problem. Each step of the nonlinear methods solves a linear least squares problem, by the normal equations or by QR.
- Systems of nonlinear equations. A square or overdetermined system has a solution exactly when , so the systems of nonlinear equations problem reduces to nonlinear least squares. Powell's dog leg was first written for this case.
- Maximum likelihood with Gaussian noise. The negative log likelihood is plus a constant, so this estimation problem is nonlinear least squares.
- Robust estimation reduces to a sequence of weighted nonlinear least squares problems through iteratively reweighted least squares.
- Bundle adjustment, calibration, triangulation and image alignment are instances, with residuals given by the reprojection error or by intensity differences.
Applications
- Curve and surface fitting in science and engineering, the classic use since Gauss.
- Camera calibration, pose estimation, homography and fundamental matrix refinement, and triangulation in computer vision.
- Bundle adjustment in structure from motion and photogrammetry, and pose graph optimization in SLAM.
- Image alignment, such as the Lucas-Kanade method, where the residuals are intensity differences.
- Geodesy and surveying, where networks of distance and angle measurements are adjusted.
- System identification and kinetics, where model parameters are fitted to measured time series.
References
- Jorge Nocedal and Stephen J. Wright, Numerical Optimization, second edition, Springer, 2006, Chapter 10, Least-squares problems (the structure of the gradient and the Hessian, the Gauss-Newton and Levenberg-Marquardt methods, large residual problems)
- J. E. Dennis Jr. and Robert B. Schnabel, Numerical Methods for Unconstrained Optimization and Nonlinear Equations, SIAM Classics in Applied Mathematics 16, 1996, Chapter 10, Nonlinear least squares (the problem, the Gauss-Newton and Levenberg-Marquardt methods and the methods for large residuals)
- Kaj Madsen, Hans Bruun Nielsen and Ole Tingleff, Methods for Non-Linear Least Squares Problems, second edition, Informatics and Mathematical Modelling, Technical University of Denmark, 2004, Chapter 1 (the problem and the conditions for a local minimizer) and Chapter 3 (the Gauss-Newton, Levenberg-Marquardt and dog leg methods)
- Richard Hartley and Andrew Zisserman, Multiple View Geometry in Computer Vision, second edition, Cambridge University Press, 2004, Appendix 6, Iterative estimation methods (the iterative minimization of geometric cost functions, robust cost functions and the choice of parametrization)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 8W9F6Q Edit this page History Report an error Markdown