Declaration: LinReg(XVals, YVals: TDoubleArray; var slope, offset, sdresid, FitQual: double): integer;
Calculates the linear regression model for the data points contained in the two arrays XVals and YVals. XVals contains the x-coordinates, YVals the y-coordinates. The calculated parameters of the regression line are returned in the variable parameters slope and offset. The parameter sdresid contains the standard deviation of the residuals, the parameter FitQual returns the goodness of fit.

The function returns the following error codes:

 0 ... everything is OK
-1 ... the number of values in XVals and YVals are not equal
-2 ... the number of values is too low (minimum of 3 values required)