The Least Squares Problem
The Least Squares Problem is one of the most important problem in numerical approximation. The main idea of the least squares problem is to solve the unknown parameters , so that the sum of the squares of the difference between the predicted value and the observed value (i.e. the error, or residual) is minimized. In short, it can be interpreted as solving the equation of . In linear algebra, there are three common ways to solve the least squares problem, and their introduction and comparison are shown as below.
The normal equations
For an overdetermined systems (): such as:
We can’t solve the system by because we can’t reach through a linear combination of and . This method only works when (It’s very unlikely when ).
Therefore, we find the vector closest to in the same plane of and , and let to be as small as possible and orthogonal to and ().
Then find a solution such that , and is the projection of onto .
Orthogonality yield
The normal equations is . It’s a least squares question and normally requires to be non-singular. It can prove that , so must have independent columns. The normal equations can be solved with Cholesky decomposition ( symm. pos. def.) but is often ill-conditioned.
The normal equations requires less operation than other methods, but it won’t work when is singular it also has a high condition number.
QR decomposition
QR decomposition is one way to solve least squares problem. The solution is shown as below.
Solving (with backward substitution) gives the least squares solution.
The merit of QR decomposition is that it has nothing to do with condition number. But the operation of QR decomposition is expensive and matrix has to be singular otherwise there will be no solution for it.
Persudo-inverse
When is a full-rank square matrix, there is a solution for that . But when isn’t a full-rank square matrix, there is no solution for this equation. So we need to find the approximate solution , and is a pseudo-inverse matrix.
Let the SVD of be
where are both orthogonal matrices, and is a diagonal matrix containing the (positive) singular values of on its diagonal.
Then the pseudo-inverse of is the matrix defined as
Note that has the same dimension as the transpose of .
If is square, invertible, then its inverse is .
If is full column rank, meaning , that is, is not singular, then is a left inverse of , in the sense that . We have the closed-form expression
If is full row rank, meaning , that is, is not singular, then is a right inverse of , in the sense that . We have the closed-form expression
The solution to the least-squares problem with minimum norm is .
Persudo-inverse will work all the time but its operation is also quite expensive due to the singular value decomposition part.
All articles in this blog adopt the CC BY-SA 4.0 agreement except for special statements. Please indicate the source for reprinting!