This page is the ground floor. The parent note throws a lot of notation at you very fast: xi, θTxi, ∥Xθ−y∥2, XTX, gradients, transposes. If any of those looked like hieroglyphs, start here. We build every single symbol from a picture before the parent is allowed to use it.
Picture a scatter of dots on graph paper. Horizontal axis = something we know (hours studied). Vertical axis = something we want to predict (exam score). Each dot is one student.
Our whole job is to draw one line through this cloud. Then, given a new student's study hours, we read the height of the line to guess their score. OLS is just a precise rule for choosing which line — the one whose total up-and-down miss from the dots is as small as possible.
Everything below is the vocabulary needed to say that sentence in mathematics.
Why does the topic need this? Because we will have to sum over all dots, and to write "add up something for every dot" cleanly we need a way to say "the i-th one".
If we only know "hours studied", then n=1. If we also know "hours slept" and "attendance percent", then n=3. Each feature is one more axis of the room the dots live in.
Recall Why can't we just picture
n=5?
Because a 5-feature dot needs 5 axes of position plus 1 for the output = 6 dimensions, and paper is 2-D. ::: We trust the algebra to do what the pictures did in low dimensions.
When there is more than one feature, a single dot's input is not one number but a list of numbers — one per feature. We call an ordered list of numbers a vector.
So xi2 has two subscripts: first says which dot, second says which feature. Read it as "x, dot i, feature 2".
Why the topic needs this: real problems have many features, and writing xi as one vector lets us handle 1 feature or 10,000 features with the same symbol.
Why bother? Because to multiply a row by a column in the matrix rules, the shapes have to line up: row-vector times column-vector gives a single number.
This one number is the prediction: "start at the intercept, then add each slope times its feature". This operation — multiply-matching-and-sum — is called the dot product.
Recall If
θ=[1,2]T and xi=[1,3]T, what is θTxi?
1⋅1+2⋅3=7. ::: (Here the leading 1 in xi is the bias slot, so the intercept θ0=1 just adds on.)
So there are two heights above each dot's horizontal position: the real dot (yi) and the point on our line directly above/below it (y^i=θTxi). The gap between them is the whole story of OLS.
Why not absolute value ∣ri∣, which is also always positive? Because the squaring gives a smooth bowl-shaped cost with a clean derivative — you'll see in the parent that x2 differentiates to 2x, which makes the calculus solvable in one step. Absolute value has a sharp corner and no clean formula.
Writing a separate line per dot is tedious. Linear algebra lets us bundle all m dots into single objects.
Why the column of 1s? Because θTxi=θ0⋅1+θ1xi1+⋯. If the first feature is always 1, then θ0 automatically becomes the intercept — no special-case code. That single trick lets us write all m predictions at once:
Set v=Xθ−y (the full column of residuals). Then ∥Xθ−y∥2 is exactly the sum of squared residuals from Section 8 — just written compactly. So the entire cost collapses to:
J(θ)=2m1∥Xθ−y∥2=2m1(Xθ−y)T(Xθ−y).
Every symbol in that line now has a picture behind it: X is the grid of dots, θ the knobs, Xθ the predictions, Xθ−y the residual arrows, ∥⋅∥2 the total squared length of those arrows.
The parent finds the bottom of the bowl by setting the gradient to zero. Full detail lives in the derivation, but here's the foundation:
That single condition, written out with all the matrix rules, becomes the parent's normal equationXTXθ=XTy. You are now equipped to read that derivation symbol by symbol.