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....



CalcPolyFit


Unit:SDL_math2
Class: TCurveFit
Declaration: function CalcPolyFit (const nOrder: byte; var kArray: array of double; var FitQual: double; var NearSingular: boolean): boolean; {Pascal}
bool __fastcall CalcPolyFit(const Byte nOrder, double * kArray, const int kArray_Size, double &FitQual, bool &NearSingular); {C++}

The method CalcPolyFit calculates the best fit for a polynomial of order nOrder. The order of the polynomial is restricted to values between 1 and MaxPolyFitOrder. The variable array parameter kArray returns the polynomial coefficients, the variable parameter FitQual returns the goodness of fit. The function CalcPolyFit returns a TRUE value if the fit has been calculated successfully, and the returned parameters are valid. Numerical instabilities which may arise from near-singular equations are indicated by returning a TRUE value in the variable parameter NearSingular. In this case the calculated polynomial coefficients should not be used.

Hint 1: The number of data used for the polynomial fit has to exceed the order of the polynomial at least by one.

Hint 2: The declaration of CalcPolyFit in C++ slightly differs from the Pascal declaration (note the extra parameter kArray_Size):
bool __fastcall CalcPolyFit(const Byte nOrder, double * kArray, const int kArray_Size, double &FitQual, bool &NearSingular);

Hint 3: The algorithm for calculating the polynomial fit has been changed with release 9.0 of the SDL Component Suite. This change results in a radical improvement of results for ill-conditioned problems (i.e. when x values are not centered around zero). Thus you should always use release 9.0, or higher, for high order polynomials. Furthermore, it is recommended to use the method CalcCenteredPolyFit whenever possible, since this routine is designed to solve even the most difficult regression problems.



Last Update: 2014-Jan-24