- NAME
ROBUST_POLY_FIT
- PURPOSE
An outlier-resistant polynomial fit.
- CALLING SEQUENCE
COEFF = ROBUST_POLY_FIT(X,Y,NDEGREE, [ YFIT,SIG, /DOUBLE, NUMIT=] )
- INPUTS
X = Independent variable vector, floating-point or double-precision
Y = Dependent variable vector
DEGREE - 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()
OB_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