Homework 8: Least Squares


Due: November 7, 2003.

Note: This won't be graded until November 10. You should be able to know if you are doing it right if your answers agree with Matlab's answers using polyfit.

Given: data file. The The observations consist of time (seconds) in the first column, and distance (cm) is in the second column. Time is assumed to be known perfectly.

Description

The data were created using a second order polynomial, with noise added to this model using Matlab's random number generator. So the model for the observations l is just the equation for a parabola:

    l = a * t2 + b * t + c

You will use least squares estimation techniques to solve for the unknown coefficients a, b, and c. You will also use Matlab's polyfit function to check your work.

Steps to follow:

  1. Read in the data file
  2. Define your l matrix.
  3. Define your A matrix.
  4. Estimate a, b, and c using least squares, (ATA)-1ATl. Print to screen.
  5. Estimate a, b, and c using Matlab's function polyfit. Print to screen.
  6. Plot your observations (symbol) and your model (line).
  7. Plot the postfit residuals as a function of time, i.e. your observations minus your model. Verify that the mean of your postfit residuals is zero. What is the standard deviation of the postfit residuals? The fact that this is close to 1 means (probably) that I used 1 when I used Matlab's random number generator.
Turn in:

Your code, plots, your answers for a, b, and c (printed to three decimal points) and questions.