1. Warren Postma
  2. CurveFit

Overview

HTTPS SSH

Least-squares Curve Fit unit

Modified by David Taylor, Warren Postma

Least-squares is a way of approximating a set of data points by an equation, allowing you to predict intermediate values or calculate some measure of the data. You may have approximated a trend-line by drawing a straight line through a number of data points plotted on a graph. Least-squares does just this "fitting" but in a mathematical way that minimises the errors that result. This unit extends least-squares from just a straight-line fit into higher order polynomials for more complex data (where there may be a physical reason for a square-law fit, for example) or for a better match to the data.

Some users are completely unaware of the mathematical names of any of these things, and have no idea what a "linear regression" is, and simply want something that does curve fitting just "like excel does", with slope, intercept, correl, and rsq functions.

David Taylor, for his HRPT Reader, had a need for a curve fitting routine that could handle a higher order fit than a simple straight-line or parabolic curve fit, and that could handle an arbitrary number of data points. He found a version of Allen Miller's Curve Fitting routine (from: the book "Pascal Programs For Scientists And Engineers", which had been typed and submitted to MTPUG in Oct. 1982 by Juergen Loewner, and corrected and adapted for Turbo Pascal by Jeff Weiss. He updated these routines to work with Delphi 4 and 5's open array parameters. which allows the routine to be generalised so that it is no longer hard-coded to make a specific order of best fit or work with a specific number of points.

Richard Kavanagh (r.kavanagh@daelnet.net) kindly supplied a C++ version which is included in the archive as PolyFitC++.zip.

Warren Postma added the chart to the demo, and added a way to force the intercept, because he needed it in order to meet certain US EPA 1631E method requirements, and has tested and maintained this sample since 2008.

fit.png

Original Downloaded from http://www.david-taylor.myby.co.uk/software/components.html (no longer online)

Stackoverflow discussion:

http://stackoverflow.com/questions/5717829/where-can-i-get-a-delphi-pascal-implementation-of-excel-style-polynomial-regress/5722449#5722449