Curve fitting is the way we model or represent a data spread by assigning a ‘best fit‘ function (curve) along the entire range. Ideally, it will capture the trend in the data and allow us to make predictions of how the data series will behave in the future.

Types of curve fitting include:

**Interpolation,**where you discover a function that is an exact fit to the data points. Since this assumes no measurement error, it has limited applicability to real life scenarios.**Smoothing**is when we find a function that is an approximate fit to the data points, but we give room for error and we allow our actual points to be near, but not necessarily on the line; given the error is minimized overall.

Specific algorithms include: gradient descent, Gauss-Newton and the Levenberg–Marquardt algorithm.

## Linear and Polynomial Curve Fitting

**Linear curve fitting,** or linear regression, is when the data is fit to a straight line. Although there might be some curve to your data, a straight line provides a reasonable enough fit to make predictions. Since the equation of a generic straight line is always given by f(x)= a x + b, the question becomes: what *a* and *b* will give us the best fit line for our data?

Considering the vertical distance from each point to a prospective line as an error, and summing them up over our range, gives us a concrete number that expresses how far from ‘best’ the prospective line is.

A line that provides a minimum error can be considered the best straight line.

Since it’s the distance from our points to the line we’re interested in—whether it is positive or negative distance is not relevant—we square the distance in our error calculations. This also allows us to weight greater errors more heavily. So this method is called the least squares approach.

**Polynomial curve fitting** is when we fit our data to the graph of a polynomial function. The same least squares method can be used to find the polynomial, of a given degree, that has a minimum total error.

## References

- Husch, Lawrence. Visual Calculus: Curve Fitting. Retrieved from http://archives.math.utk.edu/visual.calculus/0/curve_fit.5/index.html on May 13, 2018
- Gurley. Numerical Methods Lecture 5– Curve Fitting Techniques. CGN 3421 Lecture Notes. Retrieved from http://web.iitd.ac.in/~pmvs/courses/mel705/curvefitting.pdf on May 13, 2018
- Collum, David. Introduction to Curve Fitting. Retrieved from http://collum.chem.cornell.edu/documents/Intro_Curve_Fitting.pdf on May 13, 2018.
- KaleidaGraph. The KaleidaGraph Guide to Curve Fitting. Retrieved from http://www.synergy.com/Tools/curvefitting.pdf on May 13, 2018.

**Need help with a homework or test question?** With Chegg Study, you can get step-by-step solutions to your questions from an expert in the field. If you'd rather get 1:1 study help, Chegg Tutors offers 30 minutes of **free tutoring** to new users, so you can try them out before committing to a subscription.

If you prefer an **online interactive environment** to learn R and statistics, this *free R Tutorial by Datacamp* is a great way to get started. If you're are somewhat comfortable with R and are interested in going deeper into Statistics, try *this Statistics with R track*.

**Comments? Need to post a correction?** Please post a comment on our *Facebook page*.

Check out our updated Privacy policy and Cookie Policy