Consider the follow matrix A and vector b:
Find the least squares solution x for the linear system Ax = b. Use this to find a linear function whose graph best fits the points (-1,0), (0,1), (1,2), and (2,2) in .
Make sure you understand the problem fully: What is the question asking you to do? Are there specific conditions or constraints that you should take note of? How will you know if your answer is correct from your work only? Can you rephrase the question in your own words in a way that makes sense to you?
If you are stuck, check the hints below. Read the first one and consider it for a while. Does it give you a new idea on how to approach the problem? If so, try it! If after a while you are still stuck, go for the next hint.
What is the dimension of the least square solution vector x?
The equation Ax = b is overdetermined, and does not have a solution. What we mean by least square solution x is the vector that satisfies
In order to find the least square solution solve the normal equations
Now that you know it is time to look at how the matrix A and the vector b were chosen. How does this relate to the equation of a line
Consider each of the four points, one at a time.
Checking a solution serves two purposes: helping you if, after having used all the hints, you still are stuck on the problem; or if you have solved the problem and would like to check your work.
The least squares solution vector is a 2x1 vector. We can quickly find it using the normal equations.
To find from here we can either invert the matrix on the left hand side, or use gaussian elimination. We choose the latter.
best fits the four given points (x1,y1), (x2,y2), (x3,y3), (x4,y4). To answer this we need to understand how the matrix A and the vector b were chosen. We notice that b holds the y values. Further, the x values of the points, are in the second column of A. The first column of A is ones and this is because the same constant t appears for each (x,y) pair. In matrix notation
Reading line by line reveals
for j = 1,2,3,4. Comparing to y = mx + t we obtain
Therefore, the linear function is given by