The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



CalcLinFit


Unit:SDL_math2
Class:TCurveFit
Declaration:procedure CalcLinFit (var k, d, FitQual: Double);

The procedure CalcLinFit estimates the best fit of a straight line to a sample of two-dimensional data points using linear regression. The line is defined by the equation

y = kx + d.

The data points have to be entered by using the procedure EnterStatValue. A minimum number of 2 values is required in order to apply CalcLinFit. Do not forget to reset the statistics calculation before entering any new data sets (use Init)

The procedure CalcLinFit returns the following parameters: k and d define the slope and the offset of the line, and FitQual returns the goodness of fit of the regression. FitQual equals the square of the correlation coefficient. A good representation of the data samples yields a value near to 1.0 for FitQual.

Hint: The quality of fit calculated by CalcLinFit is not adjusted for the degree of freedoms in the regression parameters.

Example: CURVEFIT.DPR
  This application lets you draw points in a chart and calculate various types of regression curves. Note, that CURVEFIT.DPR uses the components RCHART and NUMLAB for the user interface, which are not included in the MATH2 package.

Example: This method is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): curvefit



Last Update: 2012-Okt-20