# Introduction to Curve Fitting

You can use the Curve Fitting functions to perform curve fitting analysis or regression.

The least squares method of curve fitting fits a curve to a particular data set. Equation A defines the least square error.

e(a) = [f(x, a) – y(x)]2 | (A)

where e(a) is the least square error, y(x) is the observed data set, f(x, a) is the functional description of the data set, and a is the set of curve coefficients that best describes the curve.

For example, if a = {a0, a1}, the following equation yields the functional description.

f(x, a) = a0 + a1x | (B)

The least squares algorithm finds a by solving the system defined by Equation C.

| (C)

To solve the system defined by Equation C, you set up and solve the Jacobian system generated by expanding Equation C. After you solve the system for a, you can use the functional description f(x, a) to obtain an estimate of the observed data set for any value of x.

The Curve Fitting functions automatically set up and solve the Jacobian system and return the set of coefficients that best describes the data set. You can concentrate on the functional description of the data without having to solve the system in Equation C.

## Applications of Curve Fitting

In some applications, parameters such as humidity, temperature, and pressure can affect data you collect. You can model the statistical data by performing regression analysis and gain insight into the parameters that affect the data.

The following figure shows a multiplot graph of the result of fitting a line to a noisy data set.

The practical applications of curve fitting include the following applications:

- Removing measurement noise
- Filling in missing data points, such as when one or more measurements are missing or improperly recorded
- Interpolating, which is estimating data between data points, such as if the time between measurements is not small enough
- Extrapolating, which is estimating data beyond data points, such as looking for data values before or after a measurement
- Differentiating digital data, such as finding the derivative of the data points by modeling the discrete data with a polynomial and differentiating the resulting polynomial equation
- Integrating digital data, such as finding the area under a curve when you have only the discrete points of the curve
- Obtaining the trajectory of an object based on discrete measurements of its velocity, which is the first derivative, or acceleration, which is the second derivative