POLY_FIT function performs a
fit with optional error estimates and returns a vector of coefficients with a length of
The POLY_FIT 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, POLYFITW, performs a weighted least square fit.
This routine is written in the IDL language. Its source code can be found in the file
subdirectory of the IDL distribution.
Result = POLY_FIT(
X, Y, NDegree [,Yfit, Yband, Sigma, Corrm]
-element vector of independent variables.
A vector of dependent variables, the same length as
The degree of the polynomial to fit.
A named variable that will contain the vector of calculated
values. These values have an error of plus or minus
A named variable that will contain the error estimate for each point.
A named variable that will contain the standard deviation in
A named variable that will contain the correlation matrix of the coefficients.
Set this keyword to force computations to be done in double-precision arithmetic.
In this example, we use X and Y data corresponding to the known polynomial
) = 0.25 -
. Using POLY_FIT to compute a second degree polynomial fit returns the exact coefficients (to within machine accuracy).
X = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
Y = [0.25, 0.16, 0.09, 0.04, 0.01, 0.00, 0.01, 0.04, 0.09, 0.16, 0.25]
result = POLY_FIT(X, Y, 2)