A line and curve fitter

The problem

Fit straight lines and parabolas to noisy data using only plain Python lists: build the normal equations, solve them by elimination, and judge the fit from the errors.

Requirements

Technologies

Step by step

  1. Create a data set of at least ten points from a known curve plus small errors.
  2. Write a function that builds AᵀA and Aᵀy for a model with k columns.
  3. Solve the system and print the coefficients, then check that the residuals add up to about zero.
  4. Fit both a line and a parabola and compare their squared errors.

Expected result

A program that recovers the hidden curve from noisy points and explains how good the fit is.

How it is evaluated

Ways to improve it