ROBUST_POLY_FIT
Name
ROBUST_POLY_FIT
Purpose
An outlier-resistant polynomial fit.
Calling Sequence
COEFF = ROBUST_POLY_FIT(X,Y,NDEGREE ,[ YFIT,SIG, /DOULBE, NUMIT=] )
Inputs
X = Independent variable vector, floating-point or double-precision
Y = Dependent variable vector
NDEGREE - integer giving degree of polynomial to fit, maximum = 6
Outputs
Function result = coefficient vector, length NDEGREE+1.
IF COEFF=0.0, NO FIT! If N_ELEMENTS(COEFF) > degree+1, the fit is poor
(in this case the last element of COEFF=0.)
Either floating point or double precision.
Optional Output Parameters
YFIT = Vector of calculated y's
SIG = the "standard deviation" of the residuals
Optional Input Keyword
/DOUBLE - If set, then force all computations to double precision.
NUMIT - Maximum number of iterations to perform, default = 25
Restrictions
Large values of NDEGREE should be avoided. This routine works best
when the number of points >> NDEGREE.
Procedure
For the initial estimate, the data is sorted by X and broken into
NDEGREE+2 sets. The X,Y medians of each set are fitted to a polynomial
via POLY_FIT. Bisquare ("Tukey's Biweight") weights are then
calculated, using a limit of 6 outlier-resistant standard deviations.
The fit is repeated iteratively until the robust standard deviation of
the residuals changes by less than .03xSQRT(.5/(N-1)).
Procedures Called
POLY(), POLY_FIT()
ROB_CHECKFIT()
Revision History
Written, H. Freudenreich, STX, 8/90. Revised 4/91.
2/94 -- changed convergence criterion
Added /DOUBLE keyword, remove POLYFITW call W. Landsman Jan 2009