LSTSQR
The LSTSQR program allows one to fit an arbitrary set of data stored in
a file or entered from the keyboard to one or more polynomial functions
of the form: Y=C0+C1*X+C2*X^2+C3*X^3+...
More than one polynomial can be fit with only a single pass through the
data since all the required summations are done during data entry. The
program first asks for a -list- of the functions which are desired. A
function is specified by typing the degree of the highest coefficient,
i.e. to fit the data to a -linear- model, specify function '1'. Note
that function '0' is just the -average- of all the data points. If one
is only seeking an empirical fit, it is often convenient to try several
different functions to see which one results in the lowest standard de-
viation. To fit data to (1) a linear equation, (2) a quadratic and (3)
a cubic, just enter '1-3' in response to the question 'Which functions?'.
Or, if you think a cubic is correct, but would just like to see how well
a simple straight-line might do, enter '3,1'.
The functions are fit in the order specified, with the report showing
the standard deviation, the number of points, the coefficients and the
estimated error in each. (Note: the full co-variance matrix is not re-
ported, but is available if required for a complete analysis.) The en-
tire list of data points and fitted values may be printed after each
analysis if desired. This option is selected by hitting any key during
the calculation, hence one can use this mechanism to get a detailed re-
port for some of the functions, but only a summary for the others. On
the other hand, if this is not convenient, a small modification to the
output routine can be made to always generate the full listing.
After selecting the desired functions, the program asks for the input
device. If entering data directly from the keyboard, just respond with
a 'CR', or else type in 'TTY'. To use data in a file, specify the name
of the device, i.e. 'SYS', 'RXA1', etc. The program will then ask for
the file name. Device and filenames may be edited during entry to cor-
rect for typing errors. Data values should be entered in 'X,Y' pairs.
(Note: if the program is finding -only- the average of a set of points
(function '0' and no other functions), data values are input one-at-a-
time, not in pairs.) Data may be formatted in many ways, for example:
1 or 1,2 or 1,2; 3,4; 5,6; ...
2 3,4 7 8 9 10 11 12 ...
3... etc. etc.
Data input is terminated either by finding a CTRL/Z (the OS/8 EOF mark)
or a ':'. Thus to enter data for four points, type '1,2,3,4,5,6,7,8:'
The response after each entry may appear a bit sluggish (especially when
fitting a high-order function) since all the summations are done during
the input loop.
Author: Jim van Zee Language: LAB-FOCAL