Repository navigation
Least Squares Minimization
Consider the following simple question: are the points
If
Can we solve this system of 3 linear equations? It is overdetermined, so it's likely there is no solution. Let's take a look at the augmented matrix:
There is no solution, so these three points are not colinear. We can verify this with a plot of the three points:
The example above shows one scenario where we end up with an inconsistent system. It's a fairly common predicament. We want a solution, but there isn't one!
Here's what we do. There is no
Definition: The
$\vec{x}$ that minimizes the distance$\large \lVert A\vec{x}-\vec{b} \rVert$ is called the Least Squares solution to$\large A\vec{x}=\vec{b}$ . The problem of minimizing this distance is called a Least Squares Problem.
Note
If
Our goal is to minimize
What we want is the vector in
This system is guaranteed to be consistent, because
Let's summarize what we derived in the video with a theorem:
Theorem: Let
$\large A$ be an$\large m\times n$ matrix, and let$\large \vec{b}$ be$\large m\times 1$ . Then the least squares solution of$\large A\vec{x}=\vec{b}$ is found by solving the normal equations:
As long as the columns of
$\large A$ are linearly independent, the normal equations are consistent.
Note
In the example to start this lesson, we had an inconsistent system
We can now find a least squares solution to this system, which we do in the video:
We see that the least squares solution gives us
In the example we just concluded, the three points are not colinear. We can't find a line that passes through each point. Instead, we found a least squares solution, and that gave us the "best fitting" line to the three points. This is a very common application of least squares.
Suppose we have data
If we write this in matrix notation, we have:
We can now just solve the normal equations
Note
We can find the best fit of any linear form in this way.
We've seen examples of using least squares minimization to find curves of best fit. This is a massive application in most STEM fields. Notably, this forms the backbone of statistics and data science. Least squares solutions are at the heart of the field of machine learning.
But we can use least squares in any setting where we have an inconsistent system. In the absence of a solution, we can find the closest thing. It's a powerful idea that relies heavily on the ideas of subspaces (the column and null spaces in particular) and orthogonal projections of vectors. This is why we develop theory in linear algebra...there's a payoff.
I can:
- Set up the normal equations for an inconsistent system.
- Set up and/or solve the normal equations to find a best fitting curve for a given dataset.