Standard Library function thatfits an n-degree polynomial curve through a set of data points using the least-squares method.
y The vector containing the dependent y-coordinates of the data. Must have the same number of elements as x.
wt The vector of weighting factors for determining the weighting of the least-squares fit. Must have the same number of elements as x. Normalize this parameter for best results.
deg The degree of the polynomial to be fitted to the data.
ybd (optional) The vector containing the error estimate of each point. (The error estimate is equal to one standard deviation.)
sig (optional) The standard deviation of the function, expressed in the units of the y direction.
mat (optional) The correlation matrix of the coefficients.
x = FINDGEN(9) y = [5., 4., 3., 2., 2., 3., 5., 6., 7.]
TEK_COLOR PLOT, x, y, Title='POLYFITW EXAMPLE'
wt = FLTARR(9) + 1.0 coeff_no_wt = POLYFITW(x, y, wt, 1, yfit)
OPLOT, x, yfit, Color=3
wt = 1.0/y coeff_stat_wt = POLYFITW(x, y, wt, 1, yfit)
OPLOT, x, yfit, Color=2
labels=['Original data',$ 'Fit with no weighting',$ 'Fit with statistical weighting'] LEGEND, labels, [255, 3, 2], [0, 0, 0], $ [0, 0, 0], 4., 1.5, .3