Least-squares geometry
A least-squares output is the attainable output that minimizes the sum of squared residual components relative to a target.
On this page 8 sections
01Real measurements rarely lie exactly on a model’s predicted pattern#
Real measurements rarely lie exactly on a model’s predicted pattern. Least squares chooses the model output whose squared differences from the measurements have the smallest sum. It gives a precise meaning to “best fit” even when the equations have no exact solution.
The matrix describes allowed output patterns, contains their weights, and is the target. The residual is one error per measurement. Squaring avoids sign cancellation and gives larger errors more weight.
In , the vector is an attainable output. Suppose a model can output for any real , but the target is . Exact equality would require and at once.
Least squares chooses the attainable output closest to the target.
For target , output leaves residual . Square both entries and add:
Output gives squared error . Smaller squared distance means closer.
Outputs are for real . Target . Closest output?
Show answer and explanation
is perpendicular to .
02For target b=(2,4) and output p=(3,3), the residual is r=b-p=(-1,1)#
For target and output , the residual is . It is perpendicular to the output direction :
In any linear output subspace, the closest output has a perpendicular residual.
Let and output . Its residual is . Expanding and adding the squares cancels the linear terms:
Since , output minimizes the error at .
Two channels output for real . Target . Minimum sum of squared errors?
Show answer and explanation
Closest output ; error .
03An input coefficient t may produce output (2t,t)#
An input coefficient may produce output . For target , the closest output is : residual is perpendicular to .
The coefficient is ; the output is the pair . Inconsistent targets leave nonzero error even at the closest output.
Outputs: , real . Target . Claim: exact fit. Closest output?
Show answer and explanation
is attainable; its error is vertical.
04A closer look#
For repeated measurements 2 and 4 that must share one fitted constant, the prediction balances errors . Their sum is zero, but the squared error is 2. This distinction is why a model can be the best available fit without matching every observation exactly.
Choose an attainable output whose residual is perpendicular to the output subspace.
- Identify the closest attainable output in an inconsistent linear system.
Sources & further reading
- [1]Margalit and Rabinoff: Interactive Linear Algebra, 6.5 The Method of Least Squares ↗Interactive Linear Algebra · Book
- [2]Margalit and Rabinoff: Interactive Linear Algebra, 6.3 Orthogonal Projection ↗Interactive Linear Algebra · Book