CLsqFit:GetNumCoefs
The GetNumCoefs method returns the number of coefficients used in the fit or the number of coefficients used in the n-th dimension of the n-dimensional polynomial fit.
CLsqFit:GetNumCoefs() CLsqFit:GetNumCoefs( nDim ) where |
nDim is an optional argument that specifies the dimension when the n-dimensional polynomial basis function is used. If, however, the polynomial is used with 1 dimension, this argument is not needed..
This method returns a value between 1 and the total number of coefficients set by the SetNumCoefs method. Depending on the basis function being used, this method returns the values described below:
n-dimensional polynomial: This method returns either the total number of coefficients being fit or the number of coefficients used in the n-th dimension. For example, if the script called SetNumCoefs( 5, 3 ), then GetNumCoefs() returns 15, GetNumCoefs( 1 ) returns 5, and GetNumCoefs( 2 ) returns 3. For dimensions higher than that specified for the polynomial, GetNumCoefs( n ) returns 1.
Hyperplane: This method returns the number of coefficients fit by the hyperplane, which includes 1 coefficient for a constant term. For example, if the hyperplane fits 5 variables, this method returns 6
User-specified basis function: This method returns the number of coefficients used by the basis function. For example, if the basis function fits 8 coefficients to 3 dimensions, this method returns 8.
The first example, below, defaults to fitting the built-in n-dimensional polynomial. This script specifies 3 coefficients for fitting a 2nd order polynomial to 1 variable. Since only 1 argument is specified, the polynomial fits 1 independent variable.
|
-- create a CLsqFit object |
|
-- set 3x5 coefficients for the n-dimensional polynomial |
|
-- return the number of coefficients |
|
-- result: n= 15 |
|
-- return the number of coefficients in dimension 1 |
|
-- result: n[1] = 3 |
|
-- return the number of coefficients in dimension 2 |
|
-- result: n[2] = 5 |
The next example used a basis function defined in the script (not the built-in n-Dimensional Polynomial). For this case, GetNumCoefs returns the number of coefficients set by the SetNumCoefs method:
|
-- create a CLsqFit object |
|
-- specify a basis function named "F" |
|
-- set 9 coefficients and 5 independent variables |
|
-- return the number of coefficients |
|
-- result: nCoefs = 9 |