LINEAR-ALGEBRA ยท Unit 14 ยท Video 3 ยท Interactive Practice
| Formula | Name | Description |
|---|---|---|
| Normal equation | Converts unsolvable into a solvable square system | |
| Projection | Closest point in the column space of to | |
| Error vector | Perpendicular to the column space: | |
| Squared error | The quantity minimized by least squares |
No line hits all three points; least squares picks the line whose total squared error is smallest.
๐ก The line passes through two of the points exactly, yet its total squared error is ; the best fit accepts a small error at every point for a far lower total of .
The projection of onto the column space is the one point where the error runs perpendicular to it.
๐ก The same test governs the video's 3D case: projecting onto the plane spanned by and leaves an error with .
Drag the data points and the normal equation recomputes the fit โ yet never changes.
AแตA = [[3, 6], [6, 14]] (fixed)
๐ก The residuals always sum to zero because 's column of ones forces the error to have no component along it โ the intercept absorbs the average.
Question 1
For the data points , , with model , the design matrix is What is ?
โ Correct! The top-left entry sums the squares of the ones column (), and the bottom-right sums the squares of the -column ().
โ Not quite. Entry of is the dot product of column and column of . Try computing each entry carefully.
Solution:
Question 2
True or False: If the system is overdetermined (more equations than unknowns), the least-squares error vector is always the zero vector.
โ Correct! An overdetermined system generally has no exact solution, so . The error measures how far is from the column space of .
โ Not quite. If then exactly โ but we said there's no exact solution! Think about what 'overdetermined' means geometrically.
Solution: False.
The whole reason we need least squares is that typically does not lie in the column space of when the system is overdetermined. If were zero, that would mean exactly, contradicting the fact that the system has no exact solution.
In our example, .
The error is zero only in the special case where the overdetermined system happens to be consistent (all equations are simultaneously satisfiable).
Question 3
For the best-fit line through the points , , , what is the total squared error ?
Hint: Compute the prediction at each , find each residual, square them, and sum.
โ Correct! The minimum total squared error is . No line can do better for these three points.
โ Not quite. Start by computing each prediction: at , . Then find each residual (actual minus predicted), square, and sum.
Solution:
Compute the prediction and residual at each data point:
| Actual | Predicted | Residual | ||
|---|---|---|---|---|
| 1 | 1 | |||
| 2 | 2 | |||
| 3 | 2 |
Question 4
To fit a parabola to data at , what would the design matrix be?
Each row corresponds to one data point, and each column to one unknown coefficient.
โ Correct! Each new term in the model adds a column to : ones for the intercept, for linear, for quadratic. The recipe generalizes to any number of terms.
โ Not quite. Each row is one data point. The columns hold the values of , , and evaluated at that point's -value.
Solution:
For the model , substitute each data point's -value:
Column 1 = ones (intercept), Column 2 = -values (linear), Column 3 = -values (quadratic).
With 3 equations and 3 unknowns, this system is square and (if is invertible) has an exact solution โ the parabola passes through all three points!
Solved: 0 / 4