The features described in this topic are obsolete
and should not be used in new IDL code.
POLYFITW
This routine is obsolete and should not be used in new IDL code. To perform a weighted polynomial fit, use the MEASURE_ERRORS keyword to POLY_FIT.
The POLYFITW function performs a weighted least-square polynomial fit with optional error estimates and returns a vector of coefficients with a length of NDegree+1.
The POLYFITW routine uses matrix inversion. A newer version of this routine, SVDFIT, uses Singular Value Decomposition. The SVD technique is more flexible, but slower. Another version of this routine, POLY_FIT, performs a least square fit without weighting.
This routine is written in the IDL language. Its source code can be found in the file polyfitw.pro in the lib subdirectory of the IDL distribution.
Syntax
Result = POLYFITW(X, Y, Weights, NDegree [, Yfit, Yband, Sigma, Corrm] [, /DOUBLE] [, STATUS=variable] )
Arguments
X
An n-element vector of independent variables.
Y
A vector of independent variables, the same length as X.
Weights
A vector of weights, the same length as X and Y.
NDegree
The degree of the polynomial to fit.
Yfit
A named variable that will contain the vector of calculated Y values. These values have an error of plus or minus Yband.
Yband
A named variable that will contain the error estimate for each point.
Sigma
A named variable that will contain the standard deviation of the returned coefficients.
Corrm
A named variable that will contain the correlation matrix of the coefficients.
Keywords
DOUBLE
Set this keyword to force computations to be done in double-precision arithmetic.
STATUS
Set this keyword to a named variable to receive the status of the operation. Possible status values are:
- 0 = Successful completion.
- 1 = Singular array (which indicates that the inversion is invalid). Result is NaN.
- 2 = Warning that a small pivot element was used and that significant accuracy was probably lost.
- 3 = Undefined (NaN) error estimate was encountered.
Note
If STATUS is not specified, any error messages will be output to the screen.
Tip
Status values of 2 or 3 can often be resolved by setting the DOUBLE keyword.