Fitting a Linear Function

This example shows how to fit a linear function to a given data sets with least squares approximation.


Problem:

Find the function which best fits the data pts: .

Solution:

The first thing we see is that and , so we get that:
We now look for such that . There are two ways to solve this: Normal Equations, and QR Equations.

To solve with normal equations we simply solve the system . This gives us that:
This tells us that and meaning that the function should be: