Using the CLsqFit Class
The CLsqFit class provides options ranging from quick and simple to involved and detailed. A gew provedures are given below, ranging from the simplest fit to using the full power of the CLsqFit class.
The following procedure fits a polynomial function to data:
1. Create a CLsqFit object using the new method.
2. Specify the number of fit coefficients using SetNumCoefs.
3. Add data to the sample using AddPt for each point.
4. Execute the fit using Fit.
5. Fetch results using GetSigmaFit and GetCoef.
The following procedure fits n-dimensional data using sample data that are either single values or RGB values:
1. Create a CLsqFit object using the new method.
2. Choose a basis function to fit. Either adopt the default n-dimensional polynomial or the hyperplane function by calling SetBasisFunc.
3. Specify the number of coefficients to fit using SetNumCoefs.
4. Add data to the sample using AddPt or AddPtWt for each point.
5. Execute the fit using Fit.
6. Fetch results using GetSigmaFit, GetCoef, GetCoefErr, GetCovar, GetResid, and other methods.
After doing the basic least squares procedure outlined above, you can add many enhancements to work with the data or refine the results:
Set one or more of the fit coefficients to specified values using ForceCoef.
Change the weight of sample points using SetPtWt.
Delete sample points using DeletePt,
Add more sample points using AddPt or AddPtWt.
Enable automatic rejection of deviant points using DoRejection.
Change the basis function or the number of fit coefficients using SetBasisFunc and SetNumCoefs.
After making any such changes, use Fit to recalculate the fit.