Curve Fitting
NOTE: If the applet below does not appear, you may need to download the latest version of Java or enable Java applets in your browser (in IE: Tools/Internet Options/Advanced/Java)
Curve Fitting Theory
Consider the problem of fitting a polynomial through a set of data points:
, ,...,
. The polynomial can be parameterized as:

where
and
are the parameters and
is the error or residual.
Note: this problem is called linear regression because the equation above is linear in the coefficients
, and not because the equation happens to represent a straight line. Fitting the quadratic
would also be a linear regression problem.
To find the straight line that best fits the data set, we use a least-squares formulation:
Minimize
where
For a straight line curve fit, the sum of squares of the residuals,
, reaches a minimum where:
and 
To express how good of a fit this best-fit line is, one can consider the coefficient of determination:

where
is the total sum of squares of the residuals between the data points and the mean:

For additional details about Linear Regression, review "Chapter 17: Least Squares Regression" in Numerical Methods for Engineers by Chapra and Canale. A succinct on-line overview can be found at Wikipedia
You can also develop a better understanding of these concepts by exploring them interactively with the applet below.
Start Exploring!
In the interactive window below you can perform the following operations:
- Move a data point: click-and-drag a data point to a different position
- Add a data point: ctrl-click in the location where you want to add it
- Remove a data point: ctrl-click on the data point to be removed
- Retrieve a pre-programmed data set: click on one of the buttons S0 through S3
- Print this entire page: click the printer button at the top right of this web-page
Learn by Exploring
Contributors : Ivan Lee and Chris Paredis
(c) Ivan Lee and Chris Paredis 2006
Last modified 10/16/2006 08:53 PM