NAME
polyfit -- fit a polynomial to sets of data
USAGE
polyfit filelist order
PARAMETERS
- filelist
- File containing X,Y, SIGMAY triples to be fit. May be STDIN, or a list of file names. Note that the third list quantity is only required if weighting = instrumental.
- order
- The order of the polynomial fit. (e.g. a parabolic fit has order 2)
- weighting = uniform
- The type of weighting for the fit. The choices are:
- uniform
- No weighting.
- instrumental
- The weight of each point is equal to 1. / SIGMAY ** 2.
- statistical
- The weight of each point is equal to 1. / Y.
- verbose = no
- If verbose = yes, additional information about the fit is printed on the standard output.
- listdata = no
- If listdata = yes, the only output will be the calculated values for the X,Y pairs. This is useful as input to graph .
DESCRIPTION
A polynomial weighted fit of specified order is fit to the X,Y, SIGMAY data triples read from the input file, files, or STDIN. The resulting coefficients of the polynomial are printed on the first line of the standard ouput. The uncertainty in each coefficient is printed on the next line. These are listed as:
a0 a1 a2 a3 ...
s0 s1 s2 s3 ...
where the polynomial has the form:
y = a0 + a1*x + a2*x**2 + a3*x**3 + ...
and the coefficients have uncertainties ("sigmas") s0 - sN.
If verbose is set to yes, the following additional information is listed: the resulting reduced chi-square, f-test, correlation coefficient, standard deviation of residuals, and number of items in the list. Also a tabular listing of each data element, X,Y, SIGMAY and the independent variable, Yc, as calculated according to the fit, is printed.
If listdata is set to yes, the only output which will appear will be the listing of X,Yc,Y, SIGMAY. This provides a list suitable as input to GRAPH or any other list oriented utility. Setting listdata to yes overrides the verbose option.
The routine REGRES from the library of routines written by Bevington is used for the fit; see Data Reduction and Error Analysis , by Bevington.
EXAMPLES
cl> polyfit STDIN 2
cl> polyfit datafile 4 verbose+
BUGS
The maximum number of data elements is currently limited to 1000 X,Y,SIGMAY triples. Also the system must be overdetermined. That is, the number of data elements must exceed the order by at least 2.
Beware of data elements having large dynamic range. The limitation of the machine exponent range can produce overflow and underflow arithmetic exceptions.