home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 24
/
CD_ASCQ_24_0995.iso
/
dos
/
educ
/
cf515
/
cf515.doc
next >
Wrap
Text File
|
1995-07-07
|
22KB
|
589 lines
July 7, 1995 (C) Copyright 1993,1995 John P. Arkins
CurveFits v5.15
---------------
LIMIT OF LIABILITY
CurveFits v5.15 is distributed as-is. Although effort has been taken
to insure accurate answers are obtained when using this program, the
author disclaims all warranties, expressed or implied. The author will
assume no liability for damages either from the direct use of this product
or as a consequence of the use of this product.
REVISION HISTORY
----------------
CF101 -- January 1992 (Never Released)
5 Fits, Maximum of 20 data pairs. Graphics screen was fixed.
Written using Turbo Pascal 6.0
CF251 -- August 27 1992
6 Fits, Graphics screen now movable and zoomable.
Written using Turbo Pascal 6.0
CF315 -- January 30 1993
16 fits, Data point limit now increased to 250.
Written using Turbo Pascal 6.0
CF427 -- February 6 1994
26 fits, External utility for converting text files added.
Written using Turbo Pascal 7.0
CF502 -- February 4 1995
26 fits. Program re-written using Borland's Turbo
vision interface. External program CONVERT.EXE written
using Turbo C++ 3.1 for greatly enhanced text file
conversion, and program can be called from within the
CurveFits program. Number of data points limited only by
FPU and size of hard disk.
Written using Borland Pascal 7.0
CF515 -- July 7 1995
28 Fits. Program revision due mainly to confusion over
whether an option to print graphs existed, it did and
does exist. Added Beta and Gamma Fits. Network
printing capabilites added. Epson printout changed
from portrait to landscape, quality is much improved.
Added some command line options to facilitate batch
operations. Floating point emulation support returns in
this version.
Written using Borland Pascal 7.0
FOREWORD
--------
CurveFits v5.xx is a signifigant revision of the CurveFits program.
The program was re-designed and rebuilt using Borland Pascal's Turbo
Vision interface. The program also no longer has a 250 data point
limit, and the size of data files are only limited by the amount of
hard disk space, and the 80 bit registers on a 80286+ PC's floating
point unit (FPU).
USING THE PROGRAM
-----------------
MENU BAR
--------
The menu bar is the white bar across the top of the screen with the
words 'File' 'Data' 'Fits' 'Window' 'Help' and 'Exit' written on it.
Each word contains a unique red letter. To access a selection on the
menu bar, press Alt and hilighted letter or click on the word with the
mouse.
Here are the subfunctions of the menu bar, listed in order :
File|Create
-----------
This option allows a user to create a new data file. You will be prompted
for a filename, and then the program will loop through the data entry
process until the user selects the Cancel button on the data entry
dialog.
File|Load
---------
This option allows the loading of a pre-existing curvefits data file.
File|Load&Fit
-------------
This is an 'express' option. It will load a pre-existing curve fits
file, run it through the curve fitting process and then take you to
the fit selection dialog. It, in effect, performs File|Load,
Fits|Perform Fits, and Fits|View Fits in sequence.
File|Change Dir
---------------
Use this to change the current directory of Curvefits.
File|View Text
--------------
Use this option to use the internal file viewer to examine text
files. This is useful for examining text data files that you may
want to import. Note that the viewer can only display 64K.
File|Dos Shell
--------------
This option will shell you to the DOS command line.
File|Set Printer
----------------
This option lets you select either a LaserJet or Epson compatible
printer, and allows printing on LPTx where x ranges from 1 to 9.
Data|Add Pair
-------------
This option allows you to add a data pair to the currently loaded
data file.
Data|Delete Pair
----------------
This option allows you to delete the highlighted data pair from
the currently loaded data file.
Data|Modify Pair
----------------
This option allows you to modify the values of the highlighted data pair.
Data|Add Loop
-------------
This allows the addition of multiple data points to data file. The
program will loop through the data pair addition process until either the
Cancel button is selected or the Esc key is pressed.
Data|Reduce
-----------
This allows you to multiply all the data pairs in a data file by
two constants. One for the X value and another for the Y value.
This is good for reducing the magnitude of data files that have
large values, ( or should I say large exponents, positive or negative)
which tend to overflow the exponential function, and the fits that
depend upon it. The range of values the 80x87's 80-bit register can
hold is approximately 3.4e-4932 to 1.1e4932. This translates roughly
to exp(-11000) to exp(11000). If these limits are exceeded during the
calculation of an equation's coefficients, the fit will become unavailable.
Data|Import Text
----------------
You will be asked for the name of the data file you wish to convert,
and a formating string for the text file data.
For numbers you wish to use you will specify the code '%Le'
in the format while numbers that are to be ignored will be specified with
'%*Le'. The format string will tell the program what each
line in your text file looks like, and therefore how it should be processed.
For example, if your text data file looked like this :
1.01232 12.8373
2.98210 4.87371
You would use this format string :
%Le %Le
If there are more than two numbers per line, you can specify which
numbers you want to use (realizing of course that CurveFits can only
use TWO data points).
For a text data file that looks like this :
16.9872E+02 16020202020.2 -1928.34E-02
123.32323 1.32233 22332.2
If you wanted to use columns one and three use this format string :
%Le %*Le %Le
or If your data appears like this :
1.4, 2.11
6.1, 12.32
Use this format string :
%Le, %Le
Compare this with the previous :
1.22982 , 12121
Format string :
%Le , %Le
Any amount of consecutive spaces can be reduced to one space
but any spacing between commas, numbers etc MUST be noted. You
must also use an %Le or %*Le for EVERY number appearing on a line.
One last more complex example:
Text File:
time = 1, velocity = 3, acceleration = 6.82287
time = 2, velocity = 4, acceleration = 5.28701
the appropriate format string is :
time = %Le, velocity = %*Le, acceleration = %Le
IMPORTANT!:
Keep in mind that THE FORMAT STRING IS CASE SENSITIVE!
If the conversion program fails immediately upon being called
it is most likely due to a incorrect format string.
The program shells to DOS and executes the program convert.exe.
Convert.exe MUST reside in the same directory as the file
CF515.EXE
For further experimentation, load a sample data file. Convert
it to a text file using the Data|Output Text option.
Clear the desktop. Now import the text file using the format string
' %Le %Le' (minus the quotes of course). Note the leading space.
If the format string is wrong the conversion fails almost immediately.
You will the get a message 'Error:empty file' because CurveFits is
trying to load the converted file which is empty.
If the format string is nearly correct, but not quite, the conversion
process make work for the first few lines and then fail.
Data|Output Text
----------------
This will convert the currently loaded data file into a text file.
The file with have the same name, but will have an extension of
'.out'
Fits|Perform Fits
-----------------
This will perform the curve fits on the currently loaded data file.
The length of this process depends on the size of the data files.
On a PC with 80386/20Mhz CPU, a data file with 100,000 points will take
about 17.5 minutes, 1000 points about 8 seconds. Note that this process is
two phased, the first phase involves calculating the coefficients, the second
determining the correlation coefficient and the maximum and standard errors.
Note that this process does NOT calculate the correlation coefficient,
maximum error or standard error for the polynomial fit. If those values are
desired, press 'C' while viewing a graph of a particular polynomial fit.
Fits|Best Correlation
---------------------
This will display, in sorted order, the available fits by best correlation.
Pressing enter will display the highlighted fit.
Fits|Best Standard Error
------------------------
This will display, in sorted order, the available fits by standard error.
Pressing enter will display the highlighted fit.
Fits|View Fits
--------------
This will bring up the fit selection menu. Fits that are unavailable will
be marked with 'N/A' (Not Available). This can happen for three reasons:
(1) Data has values which would cause calculations to have undefined
results (division by zero, logarithms of zero and below etc.)
(2) Data has caused FPU registers to overflow/underflow
(3) Polynomial fit & less than 4 data points
(Use quadratic or linear fit)
Help|Help
---------
Help can be obtained anywhere in the application by pressing F1
EDITING A DATA FILE
-------------------
Once a data file has been loaded, it can be edited. Pressing enter
will allow changing the values of the hilighted pair. Pressing the Insert
key will allow a the addition of a data point, while pressing Delete will
delete the hilighted data pair. All modifications are written directly
to the data file.
THE FITS
---------
CurveFits presently supports 28 types of fits, 19 of which are more or
less 'distinct'. The fits which are identical in some or all cases are:
Linear, Quadratic and Polynomial Fits
Exponential and Modified Power Fit
Root, Modified Hoerl and Modified Exponential Fit
Cauchy and Reciprocal Quadratic Fit
Inverse and Hyperbolic Fit
Reciprocal line and Reciprocal Quadratic Fits.
Hoerl and Gamma Fit
For some fits the LN or the inverse of input data is used in the program's
calculations. For this reason these fits cannot support data containing
zeros and negatives or data containing zeros respectively. Other fits
will also may not be available if during the curve fitting calculations
their coefficients are determined to have values which will cause infinite
or undefined results, such as c = 0 for the Gaussian Fit. When a fit is
unavailable it will appear with an N/A next to it in the fit selection
box (the box that appears when Fits|View Fits is selected).
The 28 Fits and limitations are:
Name Equation Limitations
--------------------------------------------------------------------------
1 Linear : Y=A+B*X
2 Quadratic : Y=A+B*X+C*X^2
3 Power : Y=A*X^B X and Y greater than zero
4 Exponential : Y=A*EXP(B*X) X greater than zero
5 Logarithm : Y=A+B*LN(X) X greater than zero
6 Hyperbolic : Y=A+B/X Non-zero X
7 Super Geometric : Y=A*X^(B*X) X and Y greater than zero
8 Root : Y=A*B^(1/X) Non-zero X and Y > 0
9 Polynomial : Y=A+B*X+C*X^2 Will not accept repeated
X Values for divided diff.
10 Reciprocal Line : Y=1/(A+B*X) Non-zero Y
11 Reciprocal Quadratic : Y=1/(A+B*X+C*X^2) Non-zero Y
12 Modified Power : Y=A*B^X Y greater than zero
13 Modified Exponential : Y=A*EXP(B/X) Non-zero X and Y > 0
14 Reciprocal Logarithm : Y=1/(A+B*LN(X)) Non-zero Y and Y > 0
15 Reciprocal Hyperbolic : Y=X/(A+B*X) Non-zero X and Y
16 Modified Geometric : Y=A*X^(B*X) X and Y greater than zero
17 Heat Capacity : Y=A+B*X+C/X^2 Non-zero X
18 Vapor Pressure : Y=EXP(A+B/X+C*LN(X)) Non-zero X and Y > 0
19 Exponential Step : Y=A*(1-B*EXP(-X))
20 Sinusoidal : Y=A+B*SIN(X+C)
21 Gaussian : Y=A*EXP(-(X-B)^2/(2*C^2))
Y greater than zero
22 Inverse : Y=A+B/X+C/X^2 Non-zero X
23 Hoerl : Y=A*B^X*X^C X and Y greater than zero
24 Cauchy : Y=1/(A*(X+B)^2+C) Non-zero Y
25 Modified Hoerl : Y=A*B^(1/X)*X^C X and Y greater than zero
26 Log Normal : Y=A*EXP((LN(X)-B)^2/C)
X and Y greater than zero
27 Gamma : Y=(A*(X/B)^C)*EXP(A/B)
29 Beta : Y=(A*(X^B)*(1-X)^C)
X must be a value from 0 to 1
---------------------------------------------------------------------------
POLYNOMIAL FIT
--------------
This fit requires at least four data points. If there are less than four
data points it will be unselectable. When this fit is chosen the user is
prompted for the order of the fit desired, the order referring to the
number of coefficients in the desired polynomial fit. If there are more
than twenty data points the user will be be asked for a value between four
to twenty, if there are less than twenty data points, say seventeen, the user
will be asked for a value between four and seventeen. If the order chosen
is equal to the number of data points, (seventeen in this case) the user
will then be given the option of doing the fit using either Newton's forward
divided difference or by the usual matrix method. Newton's forward divided
difference is more accurate than the matrix method however it cannot accept
repeated x values and it's order is not adjustable as is the case with the
matrix method. Note: if two or more X values are the same, Newton's
divided difference will fail.
GRAPH SCREEN
------------
DESCRIPTION OF HOTKEYS:
-----------------------
When the graphing screen is active these hot-keys support
the described actions:
F1 or H - HELP SCREEN (THIS SCREEN)
Alt-F1 - TOGGLE GRID
Pressing this will toggle the grid on and off.
F2 - TOGGLES GRID LABELING
Pressing this will toggle grid labeling on and off.
F3 - TOGGLES CIRCLING OF DATA POINTS
Loops through a sequence of data point marking
options. The first is nothing, the second is a
point, the third is a point with the addition
of a circle with a radius of one pixel, in essence
a larger dot. Pressing F3 again will increase
the radius of the circles by one pixel. After
a radius of 5 pixels, the marking then returns to
nothing again.
F4 - TOGGLES ZOOM WINDOW
This key will turn on/off the zoom window which
graphically highlights the area which will be
zoomed to when 'z' is pressed.
F5 - TOGGLES TITLING OF GRAPH
This key will turn on/off all text display on the graph
screen.
F6 - TOGGLES LINE THICKNESS
Allows you to choose either a thin or thick
line for drawing the fitted curve.
F7 - MARK DISCONTINUITIES
For fitted equations that have undefined points
(where there is division by zero), this option
will place a vertical blue line to denote that
position.
F8 - SET XSCALE = YSCALE
Sets the x and y axes to the same scale. The
scale used is the larger, which will still
show all data points.
F9 - CHANGES LINE COLOR
Allows you to choose your own color for the line
used for drawing the fitted equation.
F10 - MANUALLY CHANGE VIEWING AREA
Allows you to manually enter the coordinates
of the viewing area.
CURSOR
KEYS - MOVE VIEWPOINT OF GRAPH
The cursor keys move the viewpoint area on the graph.
For larger moves (3x), use Ctrl-Arrow Up, Ctrl-Arrow
Down, Ctrl-PgUp, Ctrl-PgDn
z Z - ZOOM IN,ZOOM OUT
[ ] - DECREASE / INCREASE X SCALE
This will increase/decrease the X distance between the
dislpayed ends of the graph.
{ } - DECREASE / INCREASE Y SCALE
This will increase/decrease the X distance between the
dislpayed ends of the graph.
/ ? - TOGGLES DIVISION OF GRID SPACING BY 2
Divides grid spacing by two. / for Y axes, ? for X axes
C - DISPLAYS EQUATION COEFF. / GET POLY R,σ,MaxErr
This displays the coefficients of the currently displayed
equation. It will also calculate the correlation
coefficient, standard error and maximum error of a
polynomial fit if it has not done so already.
D - DISPLAYS DATA COMPARISON
Will display a comparison between the original data
and the calculated values. The arrow keys will allow
the user to scroll up and down through the data.
R - RESETS GRAPH SETTINGS
Resets zoom and grid parameters and centers plot.
V - CALCULATE VALUE FROM FITTED EQUATION
Allows user to calculate a value using the fitted equation.
E - OUTPUT GRAPH TO PRINTER
This will dump the graphics screen to the
selected printer. In the registered version,
'PRESS F1 FOR HOTKEYS' will disappear. In the
unregistered version it is replaced by the
message 'UNREGISTERED SHAREWARE'. Both versions
then send a copy of the screen to the printer.
M - CALCULATE MOMENTS OF DATA
Q - PLOT RESIDUALS
P - CREATE DOS TEXT FILE
Creates DOS text file containing Equation type,
coefficients, input data, data from displayed equation
and the standard error, maximum error and correlation
coefficient.
S - SAVE CONFIGURATION
Saves the current state (line color, thickness,
data circling, data marking, grid labeling etc) to
disk in file 'CF515.CFG'.
ESC - Pressing the ESC will break any loop, including drawing
the curve and circling data.
COMMAND LINE
------------
CurveFits can send fit results to standard output via the
following options:
cf515 # /brief filename
This will output a brief description of the fit results to stdout.
This output is redirectable.
A longer description (the default) can be output this way:
cf515 # filename
Finally, to skip the intro screen and go directly to the graph
use this option:
cf515 # /view filename
In the above examples, 'filename' is of course the name of the
file, and # is a number which corresponds to the desired fit,
defined by the following table:
# Fit
---------------------
1 Linear
2 Quadratic
3 Power
4 Exponential
5 Logarithm
6 Hyperbolic
7 Super Geometric
8 Root
9 Polynomial
10 Reciprocal Line
11 Reciprocal Quadratic
12 Modified Power
13 Modified Exponential
14 Reciprocal Logarithm
15 Reciprocal Hyperbolic
16 Modified Geometric
17 Heat Capacity
18 Vapor Pressure
19 Exponential Step
20 Sinusoidal
21 Gaussiam
22 Inverse
23 Hoerl
24 Cauchy
25 Modified Hoerl
26 Log Normal
27 Gamma
28 Beta
COMPUTATIONS
------------
Standard Error:
---------------
StErr = SquareRoot(SumErrSqr/(N-2))
Correlation Coefficient:
------------------------
R = SquareRoot(1-SumErrSqr/(Sum(Y*Y)-SQR(Sum(Y)*Sum(Y))/N))
where:
SumErrSq is the sum of the sum of the squared difference between
the calculated values and actual data.
Sum(Y*Y) is the sum of the squares of the Y data
N is the number of data points
Sum(Y) is the sum of the Y data
This formula will sometimes return a correlation greater than one. This
is usually indicative of a poor fit. If a value above one is generated, it
is set to zero for the Fits|Best Correlation option.
PROGRAM
-------
CF515 uses Turbo Pascal's extended real data type. This data type allows
for 18-19 digit accuracy in computations. However, this data type requires
a math coprocessor. The program runs at a very acceptable speed on my
computer which is an 80486DX2/66MHz.
DATA FILE FORMAT
----------------
For those who wish to know the format of a CurveFits data file it is
a simple binary file whose record structure (in Pascal) is
type DataPair = record
x : extended;
y : extended;
end;
in C this translates to :
struct DataPair {
long double x;
long double y;
};
SHAREWARE NOTICE:
-----------------
The program Curvefits v5.15 and this text file are not in the public
domain, they are shareware. Please register your copy by sending $25
to the below address.
John P. Arkins
54 Pearl Street
NHP, NY 11040-3814