


        
        
        
        
        
        
        
              User Guide...
        
        
        
        
        
              ___________________________________________________________
        
        
                               DataFit 1.0  (Demo version)
        
        
                    High-powered function fitting and data modelling
        
              ___________________________________________________________
        
        
        
        
        
        
        
        
        
        
                A Soft Answer, P.O. Box 1743, Macquarie Centre NSW 2113, 
                                        AUSTRALIA
        
        






















        
                                     C O N T E N T S
                                   ===================
        
        
        
           1.  Introduction    1
        
           2.  Brief Program Description    1
        
           3.  System Requirements    1
        
           4.  Installation    2
        
           5.  Summary of Features    2
                 a) Types of function you can fit    2
                 b) Parameters    2
                 c) Maths and Arithmetic    3
                 d) Choice of four major function fitting methods    3
                 e) Publication-quality graphics output    3
                 f) Statistical analysis    3
                 g) Huge data capacity    4
                 h) Min/Maximisation and solving    4
                 i) User-friendly interface    4
                 j) Detailed reporting of results    4
        
           6.  Starting and using DataFit    5
        
           7.  Quick Reference to Commands    5
        
           8.  Files on the distribution disk    6
        
           9.  Program Navigation    6
        
           10.  Arithmetic & Maths    7
        
           11.  Alt-A  :  The ABOUT screen    8
        
           12.  Alt-D  :  DATA setup screen    8
        
           13.  More on F4 - Auto data entry    9
        
           14.  Alt-E  :  The EXECDOS setup screen    10
        
           15.  Alt-F  :  The FIT setup screen    11
        
           16.  Alt-G  :  The GRAPH setup screen    15
        
           17.  Alt-M  :  The MINMAXSOLV setup screen     18
        
           18.  Alt-O  :  The OUTPUT window    18
        
           19.  Alt-P  :  The PARAMS setup screen    19
        
           20.  Alt-R  :  The REPORT setup screen    21






        
           21.  F1 - Help    21
        
           22.  F2 - Save work file    22
        
           23.  F3 - Load a new work file    22
        
           24.  Alt-F3  -  Pick file    22
        
           25.  F5 - Zoom the function screen width    22
        
           26.  F7 - Auto-scale axis values    23
        
           27.  F8 - Printing the graph    23
        
           28.  F9  -  Select a new graph type    24
        
           29.  Alt-F9  -  Select next graph type    24
        
           30.  Ctrl-F9  -  Select previous graph type    24
        
           31.  F10 - Menu    25
        
        
        
           DataFit 1.0 -  A few case studies    26
        
           CASE STUDY 1 : DEMO1.FIT - Simple straight line fit    26
        
           CASE STUDY 2 : DEMO2.FIT - Combination of 2 curves    30
        
           CASE STUDY 3 : DEMO3.FIT - Selectivity curve    31
        
           CASE STUDY 4 : DEMO4.FIT - Manual adjustment of parameters    32
        
           CASE STUDY 5 : DEMO5.FIT - "Dangerous" Linear Regressions    33
        
           CASE STUDY 6 : FAMILY1.FIT - Fitting a family of curves    34
        
           CASE STUDY 7 : GAUSS1.FIT - 2 Gaussians    35
        
           CASE STUDY 8 : PARAMET1.FIT - Parametric equations    36
        
           CASE STUDY 9 : POLAR1.FIT - Polar coordinates    37

















        
        ====================================
        CHAPTER 1.  Introduction
        ====================================
        
           Thank you for taking the time to have a look at the DataFit demo 
           disk. DataFit is a function fitting/data modelling program which 
           has been specifically developed to be both powerful and excep-
           tionally easy to use. This document (MANUAL.DOC) is an abbrev-
           iated user manual which contains all the information you need
           to fully evaluate the program. This manual also contains a
           number of case studies which you are advised to work through.
        
        
        
        
        ====================================
        CHAPTER 2.  Brief Program Description
        ====================================
        
           DataFit 1.0 is a generalised function fitting program:
        
           *  Fit any math function through your data points quickly and 
              easily.
        
           *  Highly sophisticated techniques are used, including linear 
              and non-linear methods, algebraic manipulation, and interac-
              tive graphical manipulation.
        
           *  Comprehensive statistical and error analyses give confidence 
              limits on fitted parameters.
        
           *  Publication-quality graphs of the fitted results can be 
              printed on most printers.
        
        
        
        
        ================================
        CHAPTER 3.  System Requirements
        ================================
        
        IBM-PC or close compatible,  DOS 3.1 or later, 540K available RAM.

        Video monitor:  CGA,  EGA,  VGA, Hercules, and some others. 

        Printers:  Postscript,  HP LaserJet, most dot matrix printers.
        








                                    - 1 -




        =========================
        CHAPTER 4.  Installation
        =========================
        
           a) Insert the distribution disk into drive A: (or B:)
        
           b) Type INSTALL from the A:>_  (or B:>_)  prompt.
        
           c) Press the F2 key to read the file README.DOC, and p to print 
              it.
        
           d) Press the F3 key to read the user manual MANUAL.DOC, p to 
              print it.
        
           e) Press the F1 key to install the program files onto your hard 
              disk, or the F10 key to quit without installing.
        
              The INSTALL program gives you the opportunity to specify a 
              disk/directory to install the files, and to read and/or
              print the README.DOC and MANUAL.DOC files. It is possible to 
              run directly from the distribution floppy disk, though the 
              disk response times may be slower and you may not be able to 
              use the "swap to disk" options for printing graphs and exe-
              cuting DOS commands.
        
        
        
        
        ================================
        CHAPTER 5.  Summary of Features
        ================================
        
           a) Types of function you can fit
           ---------------------------------
        
              *  Linear or non-linear math functions with up to 6 independ-
                 ent variables;
        
              *  Parametric equations in multiple dimensions;
        
              *  Families of related curves;
        
              *  Discontinuous (piecewise-smooth) functions;
        
              *  Rectangular or polar coordinates.
        
           b)  Parameters
           ---------------
        
              DataFit will fit any function in up to 20 parameters, and up 
              to 6 independent variables (IV's). You can place lower and/or 
              upper limits on fitted parameter values.
        


                                    - 2 -




           c) Maths and Arithmetic
           ------------------------
        
              Use the standard math functions + - * / ^ ln, log, exp,
              trig and hyperbolic trig functions, plus several others such
              as factorial, gamma, random, normal, abs, sgn, max, min. Also
              use Boolean functions > < <> = >= <= which return 1 or 0 and
              can be used to specify compound functions (discontinuous or
              piecewise-smooth) acting over different ranges of values.
              Flip between up to 9 functions in each application, or import
              your own standard functions from a text file. And more.
        
           d) Choice of four major function fitting methods
           -------------------------------------------------
        
              1. Least squares linear regression. In many cases this method 
                 will even linearise the function for you before fitting.
        
              2. Levenberg/Marquadt non-linear regression. DataFit calcu-
                 lates analytical derivatives with respect to each parame-
                 ter, to achieve unprecedented convergence speeds.
        
              3. Nelder & Mead non-linear simplex method is a good work-
                 horse, which is slower than L/M but will often find a 
                 solution where L/M fails due to instability or poor start-
                 ing estimates.
        
              4. And finally, an interactive graphical fitting method. You
                 change the parameter values manually, and watch in real 
                 time how they affect the fitted function. Very powerful 
                 technique for estimating starting values if you have no 
                 idea what they should be.
        
           e) Publication-quality graphics output
           ---------------------------------------
        
              Support for PostScript, HP LaserJet & DeskJet, and most 24 
              and 9 pin printers. Plot the fitted function (or family of 
              functions), or plot the error residuals vs the dependent or 
              independent variables. Graphs are user-configurable to a high 
              degree: rectangular/polar coordinates, log/linear scales, 
              grid lines, error bars, font and symbol control, legend box, 
              programmable insertion of text and results into axis titles 
              and/or legend box, and more. Plot several graphs on a page by 
              chaining, for example to plot the fitted function with a 
              graph of the residual errors.
        
           f) Statistical analysis
           ------------------------
        
              Sophisticated statistical analysis gives you standard devia-
              tions and confidence intervals for each fitted parameter, as 
              well as covariances and correlation coefficients between 
              parameters. Plus, a Monte Carlo simulation module provides 
              the most powerful possible method for estimating confidence
                                    - 3 -




              intervals on the fitted parameters. Standard deviations on
              the data must of course be supplied. These can be set as a 
              constant for the whole data file, or varied individually for 
              each data point.
        
           g) Huge data capacity
           ----------------------
        
              Data is stored in virtual arrays which are allocated automat-
              ically to RAM, EMS, XMS or disk as required, so that immense 
              data tables can be created - even millions of data points if
              necessary. And a powerful automatic data entry facility is
              available for entering data from math functions directly into
              the table. Read and write data from/to disk. Copy/Move/Sort
              blocks of data. Fit the function to a marked block or the
              whole data file.
        
           h) Min/Maximisation and solving
           --------------------------------
        
              Find min/max values of any function, or solve functions for 
              specific values. An integrated pop-up calculator is also 
              included. Type AltC to pop up the calculator.
        
           i) User-friendly interface
           ---------------------------
        
              Intelligent use of Alt and function keys, and mouse support, 
              lets you move quickly between DataFit's functions. Backtrack 
              with Esc. Most program options are displayed on screen as 
              they become available. Pop-up help screens give interactive 
              context-sensitive help at (almost) all times. Execute Dos 
              commands or a Dos shell.
        
           j) Detailed reporting of results
           ---------------------------------
        
              Results are written as a user-configurable report, which can
              be scrolled in a browse window or directed automatically to
              disk or printer. Or highlight sections from the browse window
              and send to disk or printer.
        
        
        











                                    - 4 -




        ========================================
        CHAPTER 6.  Starting and using DataFit
        ========================================
        
           Start the demo program by typing datafit at the DOS prompt. 
           Finding your way around the program is very easy once a few
           rules are understood:
        
           *  Use the Alt-keys to activate the options shown on the top 
              line of the screen. eg. AltF to Fit, AltX to eXit etc.
        
           *  Function keys F1 to F10 (though not all of them) are shown on 
              the bottom line of the screen.
        
           *  If you have a mouse installed, try clicking on various parts 
              of the screen. Click on arrows, keywords, data entry windows, 
              etc. The mouse tries very hard to find something intelligent 
              to do whenever you click it. Left button selects, right 
              button is usually equivalent to pressing the Esc key (to
              cancel, or backtrack through previous options).
        
           *  Press the F1 key for help at any stage. The help screens are 
              hypertext - ie. you can move the highlight (if one is visi-
              ble) with the arrow keys, to select more help on various
              topics by pressing Enter on a highlighted phrase. Press Esc
              to return to the program.
        
        
        
        
        =========================================
        CHAPTER 7.  Quick Reference to Commands
        =========================================
        
           Alt-D   Use the Data table
           Alt-E   Execute a DOS command or shell
           Alt-F   Fit the function
           Alt-G   Graph  (display graph on screen)
           Alt-O   Read the program output
           Alt-P   Define data columns and parameters
           Alt-R   Define options for the output report
           Alt-X   Exit the program
        
           F1      Help
           F2      Save work file
           F3      Load a new work file
           Alt-F3  Load a previously-used file
           F4      Auto data entry into the data table
           F5      Zoom the function screen width
           F7      Auto-scale axis values
           F8      Print Graph
           F9      Select graph type
           Alt-F9  Select next graph type
           Ctrl-F9 Select previous graph type

                                    - 5 -




        ============================================
        CHAPTER 8.  Files on the distribution disk
        ============================================
        
           readme  .doc        Read this file
           install .exe        The installation program
           startup .txt        Text file for startup information
           datafit .exe        The DataFit program
           datafit .hlp        Hypertext help file for DataFit 
           blank   .fit        DataFit data file: Blank (new) 
           demo1   .fit        data file: Simple straight line fit 
           demo2   .fit        data file: Combination of two curves 
           demo3   .fit        data file: Selectivity curve
           demo4   .fit        data file: Manual adjustment of parameters 
           demo5   .fit        data file: "Dangerous" linear regressions 
           family1 .fit        data file: Fitting a family of curves 
           gauss1  .fit        data file: Two Gaussians
           paramet1.fit        data file: Parametric equations 
           polar1  .fit        data file: Polar coordinates
           general .fns        Short list of standard functions 
           prtgrf  .exe        For printing graphs when "swapping to disk" 
           deffont .glf        SansSerif graphics font file
        
        
        
        
        ================================
        CHAPTER 9.  Program Navigation
        ================================
        
           Finding your way around the program is very easy once a few 
           rules are understood:
        
           *  Use the Alt-keys to activate the options shown on the top 
              line of the screen. eg. AltF to Fit, AltX to eXit etc.
        
           *  Function keys F1 to F10 (not all though) are shown on the 
              bottom line of the screen.
        
           *  If you have a mouse installed, try clicking on various parts 
              of the screen. Click on arrows, keywords, data entry windows, 
              etc. The mouse tries very hard to find something intelligent 
              to do whenever you click it. Left button selects, right
              button is usually equivalent to pressing the Esc key (to
              cancel, or backtrack through previous options).

           *  Press the F1 key for help at any stage. The help screens are
              hypertext - ie. you can move the highlight (if one is visi-
              ble) to select more help on various topics. Press Esc to 
              return to the program.
        




                                    - 6 -




        =================================
        CHAPTER 10.  Arithmetic & Maths
        =================================
        
           Arithmetic: +    addition,           2+3  =  5
                       -    subtraction,        2-3  =  -1
                       *    multiplication,     2*3  =  6
                       /    division,           2/3  =  0.666..
                       ^    raising to a power, 2^3  =  8
        
           Trigonometric:    sin, cos, tan, asin, acos, atan. (radians)
        
           Hyperbolic Trig:  sinh, cosh, tanh, asinh, acosh, atanh.
        
           Other1:     ln(x)      -  Naperian logarithm
                       log(x)     -  Base 10 logarithm
                       exp(x)     -  exponential
                       sqrt(x)    -  square root
                       sqr(x)     -  x^2
                       cube(x)    -  x^3
                       pow4(x)    -  x^4
                       abs(x)     -  absolute value
                       int(x)     -  integer part of x
                       round(x)   -  x rounded to nearest whole number
                       sgn(x)     -  returns 1 when x>=0, -1 when x<0
                       gamma(x)   -  gamma function
                       gammaln(x) -  ln(gamma(x))
                       fact(x)    -  factorial (x rounded to whole number) 
                       factln(x)  -  ln(fact(x))
                       random(x)  -  random number between 0 and x
                       normal(x)  -  normally-distributed random number 
                                     with a mean of 0, peak of 1, and 
                                     standard deviation x.
        
           Other2:     max   -  maximum of two numbers, (3 max 5) returns 5 
                       min   -  minimum,  (3 min 5) returns 3
                       div   -  integer division, (14 div 3) = 4
                       mod   -  remainder of integer division, (14 mod 3)=2
        
           Logical:    =  >  >=  <>  <  <=
        
              These logical functions have two arguments, much like + - * / 
              and ^, and the result is returned as 0 or 1 for FALSE or 
              TRUE.
        
              Examples: (5+3)>2    returns the result 1
                        sin(x)>=2  returns the result 0

           Boolean:    and  or  xor  not(x)
        
              These Boolean functions have two arguments ("not" has one), 
              much like the logical functions. The arguments are considered 



                                    - 7 -




              to be TRUE if they are greater than 0, otherwise FALSE. The
              result is returned as 0 or 1 for FALSE or TRUE.
        
              Examples:     ((5+3)> 2 or sin(x)>=2) returns the result 1
                            not(a>b)    is the same as  a<= b
                            (5 and 3)   returns the result 1
        
           Logical and Boolean functions can come in handy to describe a 
           combination of two or more functions acting over different 
           ranges.
        
        
        
        
        =========================================
        CHAPTER 11.  Alt-A  :  The ABOUT screen
        =========================================
        
           Typing AltA displays a copyright message and general information 
           about the developer of the program.
        
        
        
        
        ==========================================
        CHAPTER 12.  Alt-D  :  DATA setup screen
        ==========================================
        
           The Data Table holds the data to which the function/s will be 
           fitted. It can also be used to hold standard deviations of 
           individual data points, some of the results of the function 
           fitting, and it holds temporary data used for Monte Carlo simu-
           lations.
        
           The data table can have up to 24 columns, and any number of 
           rows. The table will be located in RAM memory if enough is 
           available, otherwise it will be allocated to EMS or XMS (if 
           available) or to virtual memory on a hard disk. EMS and XMS are 
           slower than RAM, and a disk-based data table is MUCH slower than 
           either. So the moral is to make your data table just big enough 
           for the job, to keep it in the fastest memory location.
        
           The default size of the data table is 1000 rows by 6 columns. 
           This default size can be changed in two ways:
        
           1) When starting DataFit: Use the /d option to set the maximum 
              rows and columns for the data table. Minimum 100 rows and 2 
              columns. Examples:  datafit /d500      (500 rows, 6 columns)
                                  datafit /d5000:10  (5000 rows, 10 cols)

           2) While using DataFit: Type F7 to change the number of columns,
              or AltF7 to change the number of rows. You will have to write
              any data in the table to a disk file first, then delete the
              data, change the number of rows and/or columns, and finally
              read the data back in from the disk file.
                                    - 8 -




           A number of control and function keys can be used to help make
           your data entry more efficient. Either press the key or click on 
           the phrase with a mouse:
        
           Ctrl left/right arrow  - Change column
        
           CtrlD  - Delete the line the cursor is on
        
           CtrlI  - Insert a line at the cursor position
        
           CtrlT  - Mark the current line as "top of block"
        
           CtrlB  - Mark the current line as "end of block"
        
           CtrlC  - Copy a marked block to the cursor position
        
           CtrlK  - Unmark a marked block
        
           CtrlV  - Move a marked block to the cursor position
        
           CtrlX  - Delete a marked block
        
           CtrlS  - Sort a marked block on the current column.
        
           F4     - Auto data entry. See next section for details.
        
           F5     - Read data from a disk file
        
           F6     - Write block to a disk file
        
           F7     - Change the number of columns
        
           AltF7  - Change the number of rows
        
           Note: If a block is marked when AltF is pressed then fitting 
           will be done only on the data in the marked block. Unmark the 
           block with CtrlK to fit the whole data file.
        
        
        
        
        ===========================================
        CHAPTER 13.  More on F4 - Auto data entry
        ===========================================
        
           Type F4 while using the data table to pop up an "Auto Data 
           Entry" setup screen. This is a very powerful utility which lets 
           you enter data sequentially into the data table. Very useful for 
           inserting data which follows a math function. Say for example 
           you want to overwrite the data in columns 1, 2 and 4, for rows 
           21 to 90, and leave the other columns unaltered. And say you 
           want to enter 101 to 170 in column 1, the square root of column
           1 into column 2, and the square of the differences between them
           into column 4. Then you move the cursor to row 21 (any column)

                                    - 9 -




           and type F4. Then you would set up the table like this:
        
           FORMULAE:  Enter f(i) for each column....i=1 to [70   ] (lines) 
           ---------------------------------------------------------------
           ( ) Insert lines of data (else overwrite existing data) 
           Enter functions in i. Only marked columns will be modified. 
           (*) Column1 =[100+i                                          ] 
           (*) Column2 =[sqrt(c1)                                       ] 
           ( ) Column3 =[                                               ] 
           (*) Column4 =[sqr(c2-c1)                                     ] 
           ( ) Column5 =[                                               ] 
           ( ) Column6 =[                                               ]
        
        
           The first line defines an index, i, to run from 1 to 70. The 
           "Insert lines..." line is switched off to indicate overwriting 
           of existing data. Then the setup lines for columns 1, 2 and 4 
           are marked (*), and the others left unmarked.
        
           Finally the three formulae for columns 1, 2 and 4 are entered. 
           Note that you cannot use any variables or parameters from the 
           "Params" screen here. You can only use constants, the normal 
           math functions, the index variable i, and variables c1 to c24 
           which will return the value of the data in columns 1 to 24 of 
           the row being altered.
        
           When you have set up the data press F4 again to proceed with 
           entering the data into the data table, or Esc to return to the 
           data table without entering the data.
        
        
        
        
        =================================================
        CHAPTER 14.  Alt-E  :  The EXECDOS setup screen
        =================================================
        
           You can execute any DOS command, or enter a DOS shell while 
           using DataFit. Type AltE to open a DOS command window. Type in 
           the DOS command, and press Enter to execute it. When the command 
           has been completed you will be instructed to press any key to 
           return to the program.
        
           If no command was entered (the DOS command was a blank line) 
           then you will enter a DOS shell. You will see the normal DOS 
           command line. Continue executing DOS commands as required, and 
           type "exit" as the DOS command to return you to the DataFit 
           program.
        
           The above method gives a quick way to execute small DOS applica-
           tions using whatever memory is available at the time. If there 
           is not enough memory to execute the DOS command, then type AltE 
           again instead of Enter. This will swap out DataFit to make more 
           memory available before executing the DOS command or DOS shell.
        
                                    - 10 -




        =============================================
        CHAPTER 15.  Alt-F  :  The FIT setup screen
        =============================================
        
           a) The top line of the "Fit" window shows the current function 
              number (1 to 9) and the list of independent variables which 
              have been defined and assigned data column numbers in the 
              AltP "Param" window. f(x) in this example.
        
           b) Enter up to 9 separate functions, and use Alt-1 to Alt-9 to 
              select one for fitting. Type F5 to zoom to wide screen for 
              long functions. Use a semicolon to mark the end of the func-
              tion, if you want to add comments. The function must use all 
              the independent variables (see paragraph a), and can be up to 
              255 characters in length.
        
              Example.    1. f(x) =
                         [a+b*x    ;straight line                 ]
        
              You can also define a system of parametric equations: the 
              coordinate in each dimension varies with a parameter which 
              must be called t. This is just slightly tricky, and requires 
              a bit of setting up in the "Param" window. t must be defined 
              as a parameter (constant), and its data column must be speci-
              fied in the "f(),Data...[ ]" line. There must also be one 
              independent variable defined for each dimension of the fit. 
              And finally, you indicate a parametric fit by using commas in 
              the "Fit" function line.
        
              Example:   1. f(x,y) =
                        [a*cos(t),b*sin(t) ;ellipse           ]
        
              See the case study on "PARAMET1.FIT" for a detailed descrip-
              tion on fitting parametric equations.
        
           c) You can also create your own library of standard functions. 
              The AltT command opens a text file, and lets you select one 
              line of the file to be entered as the current function. A 
              sample file GENERAL.FNS is included on the distribution disk.
        
           d) Once the function is entered, select a type of method to use 
              for fitting:
        
              1. Linear regression: Much more than a simple straight line 
                 fit. Any function which can be transformed so that it can 
                 be expressed in a form which is linear in its variable 
                 parameters can be fitted by linear regression. The trans-
                 formation is even done for you provided you write the 
                 function in a standard form:
        
                 f(x,y,z,...) = f2([..] + a*[..] + b*[..] + ...)
        



                                    - 11 -




                 where [..] indicates a constant or any function of the
                 independent variables (parameters being fitted not al-
                 lowed), and f2 can be blank or a function such as exp, ln,
                 sqr, or sqrt. eg. f(x) = ln(a+b*x+c*x^2). See DEMO1.FIT
                 and DEMO5.FIT.
        
                 Linear regression is very fast as it is a once-through
                 (non-iterative) method. But you may not always be happy
                 with the results, especially when a linearising transfor-
                 mation is applied as in the DEMO5 example. The reason is 
                 that the function is fitted to a transformation of the
                 data rather than the original data itself. When both are
                 transformed back again after fitting, the fit may appear
                 to be biased in some way. If this happens you should
                 select the Levenberg/Marquadt method.
        
              2. Levenberg/Marquadt: This is the fastest and most powerful 
                 procedure for fitting non-linear functions - ie any func-
                 tion that you can type in on the function line. This 
                 method is difficult to generalise as it requires the 
                 analytical derivatives with respect to each fitted parame-
                 ter. No problem for DataFit though, as sophisticated 
                 algebraic routines do the differentiation for you. This 
                 feature is believed to be unique among all generalised 
                 function fitting procedures.
        
                 Levenberg/Marquadt can be a bit quirky though, especially 
                 on extremely non-linear functions or when poor starting 
                 estimates are supplied. If it fails, try Nelder & Mead 
                 first, and try Manual adjustment if you still have trou-
                 ble. It is often a good idea to use Nelder & Mead until it 
                 appears to be approaching a solution, then interrupt the 
                 fit (press any key) and switch to Levenberg/Marquadt to 
                 finish off rapidly.
        
              3. Nelder & Mead:  The method proposed by Nelder & Mead is 
                 actually a function minimisation method rather than a 
                 curve fitting method. Here though the curve fitting is 
                 achieved by minimising a function defined as the sum of 
                 the squares of the differences between the fitted function 
                 and the data, to achieve the same result as a function 
                 fitting procedure.
        
                 The method is known as a downhill simplex method (unrelat-
                 ed to linear programming, which is also described as a 
                 simplex method, though for different reasons). It is crude 
                 and slow in comparison to the Levenberg/Marquadt method, 
                 but it exhibits exceptional stability and will often find 
                 a solution where L/M fails due to poor starting estimates, 
                 or a highly non-linear function.
        
                 It is often efficient to use Nelder & Mead until it seems 
                 to be getting quite close to a solution, then switch to 
                 L/M to zero in quickly. Note that Nelder & Mead may give a 
                 slightly different solution to L/M, as it uses different
                                    - 12 -




                 criteria to decide when a solution has been reached. You,
                 the researcher, must decide which solution is "best". This 
                 is usually be st done by inspecting the graph of the 
                 fitted function plotted on the data points, in conjunction 
                 with the residuals graphs.
        
                 The NORMALISE option can be selected as a variation of the 
                 standard Nelder & Mead procedure. In this case the sum of 
                 the squares of [errors as a fraction of the data value] is 
                 minimised, rather than the SSQ of [actual errors]. This 
                 biases the fit in favour of small data values. You might 
                 consider this option for example when you are plotting 
                 your data on log scales, and they cover several decades of 
                 values on the axes. It will give a more even-looking fit 
                 when plotted on log scales, where the other methods may 
                 seem to fit poorly at small values and well at larger 
                 values.
        
              4. Manual (Graphical) adjustment: If you can't get any of the 
                 above procedures to work, it may be that your starting 
                 estimates are simply unreasonable. This option is a very 
                 powerful method for seeing the effects of individual 
                 parameters on the shape of the function you are fitting. 
                 More importantly though, it lets you use the best (though 
                 not necessarily the fastest) non-linear function fitting 
                 procedure of all - your own brain.
        
                 When you initiate a fit with this option selected, you are 
                 presented with a graphic image showing the data, the 
                 function with its current parameter values, and at the top 
                 right of the screen a window showing the current parameter 
                 values. The left/right arrow keys decrease or increase the 
                 value of the factor F, shown in the window. Up/down arrows 
                 select a parameter, then use + - * / to add, subtract, 
                 multiply or divide the parameter by the factor F. You can 
                 also use A, S, X, D for + - * /, which is more convenient
                 once you get used to it. Every time you change a 
                 parameter's value the function is re-drawn at the new 
                 value, so you can quickly see how the function is affected 
                 by the parameters.
        
                 Press Esc when done. The normal report is compiled at the 
                 current parameter values, and if you feel your function 
                 now is a ball-park fit then you can select one of the 
                 other methods to complete the fit.
        
           e) Monte Carlo simulation is the most powerful available method 
              for estimating standard deviations and confidence limits on 
              your fitted parameters, PROVIDED you can specify accurate 
              standard deviations on your experimental data. See "Params" 
              for specifying these standard deviations.
        
              If you specified standard deviation data on your data points 
              then the Linear Regression and Levenberg/Marquadt methods 
              will also give estimates of standard deviations and confi-
                                    - 13 -




              dence limits on your fitted parameters. And if your errors
              are normally distributed then you can be reasonably confident 
              in the error estimates on the fitted parameters. The Nelder & 
              Mead method is unable to return any error estimates of this 
              nature.
        
              But Monte Carlo takes the process of error estimation consid-
              erably further. And in the case of Nelder & Mead this is the 
              only method for estimating errors in the fitted parameters.
              It works like this: First do the simulation as normal, using 
              the method selected, and store the values of the fitted 
              parameters. Then repeat the fit a number of times, but with 
              each repetition the original data to be fitted are varied by 
              a normally- distributed random variable with the standard 
              deviation specified in the "Params" section. In other words, 
              this is about the closest you can come to simulating a large 
              number of fits on different samples of the data, all varying 
              by some standard deviation. Each fit generates a new set of 
              fitted parameters, and if enough fits are done then the 
              fitted parameters can have their standard deviations and 
              confidence limits accurately determined.
        
              Clearly the original data mustn't be destroyed, so a "Monte 
              Carlo" data column must be allocated in the "Params" section. 
              This must be a data column which is not used for any other 
              purpose in the program. Also, you really should do at least 
              100 iterations (set alongside the Monte Carlo check box) for 
              the results to be meaningful. This could take a long time of
              course, so do your fit first without Monte Carlo simulation,
              then when you are ready you can select Monte Carlo for a
              final run-through to get the parameter error estimates.
        
           f) Maximum iterations provides the option for stopping a simula-
              tion after some maximum number of iterations has been done.
        
           g) The convergence criterion tells the program how hard to try 
              to find a solution. It is used only by the non-linear proce-
              dures, and it is quite important. If it is too large t hen 
              the program may decide prematurely that it has converged. 
              This is often ( but not always) immediately noticeable when 
              plotting - the function quite obviously does not fit through 
              the points as well as it could. If it is too small, the 
              program may fail to converge. It may reach a solution, but be 
              unable to satisfy the convergence criterion. This will
              sometimes be obvious by watching the iterations window and 
              the parameter values. So what is "too large" and what is "too 
              small"? Unfortunately that depends on both the problem and 
              the type of fitting method chosen, and that is why it is 
              provided as a value to be entered by the user. But, that 
              having been said, it should also be noted that a value of 1e-
              4 to 1e-6 will be satisfactory in most cases.
        
           h) The error limit on data is a safety valve designed to help 
              protect against fatal evaluation errors when the program runs 
              out of control (which it can do quite easily on some types of 
                                    - 14 -




              functions, especially when very poor starting estimates are
              supplied). The fit will be terminated if the value of the 
              function with current parameters exceeds the data by the 
              factor supplied. 1e6 seems to be a reasonable value for most 
              cases, but you can change the value, or deactivate this 
              option by unchecking the box.
        
        
        
        
        ===============================================
        CHAPTER 16.  Alt-G  :  The GRAPH setup screen
        ===============================================
        
           The "Graph" setup screen not only gives you tremendous control 
           over the presentation of the graph of the fit, it also gives you 
           instant access to several types of graph. The primary type is of 
           course a plot of the fitted function vs the data points.
        
           If the fitted function has more than one independent variable 
           (IV) then the curve and data are plotted vs the first IV defined 
           in the "Params" setup screen. 3-D plots for 2 IV's are felt to 
           be of limited value due to the perspective problem of estimating 
           errors between data and function on a flat image. And for more 
           than 3 IV's it becomes effectively impossible to represent any 
           sort of function vs data plot. This is one major reason for 
           using the residuals plots...
        
           It is informative (and even necessary in the case of multi- 
           dimensional data) to plot the residuals vs either the independ-
           ent variables (IV's) or the function response values, f(). Type 
           F9 and a window pops up showing the available graph types. The 
           number of available graph types depends on the number of IV's,
           as there is one for the fitted function, one for residuals vs 
           function, and one each for residuals vs each IV. Select one and 
           press Enter to switch to that graph type. The current graph type 
           is shown in the top border of the "Graph" setup screen.
        
           Once you have selected the type of graph, you need to fill in 
           the data to describe the graph layout. Most of it is pretty well 
           self-explanatory (or at least it is intended to be!) if you are 
           familiar with scientific graphs.
        
           But the text entry lines (for axis titles and legend table) are 
           certainly NOT entirely self-evident, as they can make use of a 
           powerful facility for automatically entering items such as the 
           function itself, and values of parameters used in the function 
           (or even math functions of the parameter values). You can also 
           add sub- and superscripts. The process works like this:
        
           1. If the whole text string is a valid math expression, such as 
              a, or sqrt(a/b) etc, then the value of that math expression 
              is output (in the format specified in the "Report" setup 
              screen).
        
                                    - 15 -




           2. If the string is not recognised as a valid math expression,
              then it is written exactly as is.
        
           3. What about a combination of text and math expressions then? 
              You enclose the text b its in "quotes" and the math expres-
              sions outside the quotes, each entry separated by commas. For 
              example, the text expression ["a = ",a] returns the string [a 
              = 1.23] or whatever the value of a is (the square brackets 
              are for clarity here, and are not actually entered in the 
              setup screen). If there are any errors in the line then the 
              line is printed literally.
        
           4. You can also include the text description of your function 
              automatically in these text entry lines. The current function 
              entered into the "Fit" screen can have an optional comment 
              attached (a semicolon ; indicates the end of the function and 
              the start of comments). Insert  ~F  to include the whole 
              function line including comments into the text. Insert  ~f  
              to include the function only, without comments. These MUST be 
              within "quotes". Any errors will result in the line being 
              printed literally.
        
           5. Finally, you can introduce sub and superscripts into the text 
              lines. Use ~+  to change to superscript,  ~-  for subscript, 
              and ~#  to return to normal. As before, these must be within 
              "quotes" or the line will be written literally.
        
           Some of the other options are explained very briefly here:
        
           *  Polar coordinates assumes your data is in (theta,r) format,
              and transforms them onto polar coordinates:
              [x=r*cos(theta),y=r*sin(theta)]
        
           *  Overlay Graph lets you plot several graphs on the page by 
              chaining another graph onto the current one. Several graphs 
              can be chained together on the page in this way. See 
              GAUSS1.FIT for an example. Type F9 to see the graph numbers.
        
           *  Fast screen text does not affect the printed output; it draws 
              text in a fixed but very fast font for faster screen plot-
              ting.
        
           *  SansSerif/Helvetica font can be selected as an alternative to 
              the default stroked font. This is better with high resolution 
              printers, but may be less legible with lower resolution 
              printers. Also, the default font is a fixed-pitch font and 
              will line up columns of text, whereas the SansSerif/Helvetica 
              font is a variable-pitch font.
        
           *  The font size can be specified separately for the axis 
              values, the axis titles, the symbol size, and (see later) the 
              legend table.
        
           *  You can choose to join the data points by straight line 
              segments or one of five data symbols. 0=line segments, 
                                    - 16 -




              1=circle, 2=square, 3=triangle, 4=inverted triangle, 5=dia-
              mond. And they can be filled or hollow.
        
           *  You can add error bars if standard deviation data were sup-
              plied in the "Params" setup screen, and specify the width of 
              the top and bottom caps on the bars.
        
           *  Specify lengths of x and y-axes, and their offset, or dis-
              tance in inches from the left or bottom of the page.
        
           *  Specify min/max values on x and y-axes; the INTERVAL between 
              major tick marks; the NUMBER of minor ticks per major tick 
              interval; decimal places and notation; grid lines on major 
              and/or minor tick marks; and log scales on the axes.
        
           *  The 'Plotting Range', to the right of the min & max values 
              line, lets you plot your function over just part of the x-
              axis range. Leave these values as 0 and 0 to plot over the 
              full axis range.
        
           *  You can include a table of contents with optional drop-shad-
              ow. This will be overlaid over the graph axes and grid lines, 
              but will not clear any data points if they happen to lie on 
              the legend table. You can specify the size and location of 
              the legend table, font and font size, and several lines of 
              text in the table. The lines of text can include the math 
              expressions etc described earlier in this section.
              Example: "a = ",a

           *  Finally, if you are plotting a function in more than one
              independent variable then you will see an additional line at
              the end of the "Graph" setup screen. This line lets you enter
              values for the additional independent variables:  The graph
              of the fitted function is always plotted with respect to the
              first independent variable, as defined in the "Param" setup 
              screen. When more than one IV is used, the additional IV's 
              must be given specific values for the plot. Values for sever-
              al IV's on the same curve are separated by commas. Values for 
              multiple curves on the same plot are separated by semicolons.
        
              Example:  if the function has 3 IV's, such as  f(x,y,z)=...,
              then you might define:  [y=1, z=1; y=1, z=2; y=2, z=2; ] See 
              the demo file FAMILY.FIT for an example of plotting several 
              curves.
        
        
        






        

                                    - 17 -




        ====================================================
        CHAPTER 17.  Alt-M  :  The MINMAXSOLV setup screen 
        ====================================================
        
           The "MinMaxSolv" setup screen is used to find the minimum or 
           maximum value of a function, or to solve a function for a spe-
           cific value.
        
           a) Type Alt1 to Alt9 to copy function 1 to 9 from the "Fit" 
              setup screen to the current "MinMaxSolv" function.
        
           b) Select the type of solution you require: Minimise, Maximise, 
              or Solve. If you select Solve then enter the function value 
              you require on the "Solve for f(..)" line.
        
           c) The solution is found by non-linear regression using the 
              Nelder & Mead routine (see "Fit"). This is certainly not the 
              fastest or the most efficient method, but it is a very gener-
              al method which will solve most problems provided you supply 
              a reasonable starting estimate.
        
           d) The "error limit" serves a similar purpose to that described 
              for the "Fit" setup screen. It prevents a run-away solution.
        
           e) Make sure to enter a "Start value" as your starting guess for 
              the solution. A poor starting estimate may mean no solution 
              is found, or even the wrong solution (eg. for functions with 
              multiple local minima or maxima). If your function has more 
              than one independent variable then you need to enter a start-
              ing guess for each independent variable.
        
        
        
        
        ==========================================
        CHAPTER 18.  Alt-O  :  The OUTPUT window
        ==========================================
        
           Program results are written to an internal buffer, so you can 
           scroll through them later. Use the obvious commands such as 
           Home, End, PgUp, PgDn, and arrow keys.
        
           Also use:  
        
           b  -  Mark bottom screen line as bottom of block
        
           c  -  Clear the output buffer
        
           f  -  Find (search) a text string
        
           g  -  Find again (repeat last Find)
        
           h  -  Hide the marked block
        

                                    - 18 -




           p  -  Print marked block, or all if not marked
        
           r  -  Read any file from disk
        
           t  -  Mark top screen line as top of block
        
           w  -  Write marked block to disk, or all if not marked
        
           mouse-  click on a line to mark block begin/end
        
        
        
        
        ================================================
        CHAPTER 19.  Alt-P  :  The PARAMS setup screen
        ================================================
        
           The "Params" setup screen is used to:

              *  define the independent variable/s which your function uses;
              *  specify which columns in the data table will hold various
                   data;
              *  specify what standard deviation data are available, if any;
              *  define any parameters to be used in the function;
              *  specify which parameters are constant, and which will vary;
              *  assign values to constants, & parameter starting estimates;
        
              Some instructions are shown to the left of the "Params" setup 
              screen, indicating various required and optional data. You 
              need to define at least one independent variable (IV), though 
              your function can have up to 6 IV's.
        
              Example:  f(x) = a+b*x      has 1 IV, called x
                        f(r) = c/r        has 1 IV, called r
                        f(x,y,z) = a+x+b/y^2+c*ln(z)   has 3 IV's (x,y,z)
        
              Each IV must be assigned a column number in the data table, 
              where the individual data vectors are located. The function 
              value, f(x) etc, must also be assigned a data column number 
              to hold the function value at each data vector. Enter this in 
              section (b) at the line which says f(),Data...[--].
        
              Below that line are three additional (and optional) data 
              column allocations. You can leave them as 0 to ignore them, 
              or fill in a valid column number to activate them:
        
              1. 'Fitted' is a column which will hold the fitted function 
                 value corresponding to each data vector after the fit has 
                 been completed.
        
              2. 'Residuals' is a column which will hold the residual error 
                 (ie the difference between the fitted function and the f() 
                 data) corresponding to each data vector after the fit has 
                 been completed.
        
                                    - 19 -




              3. A 'MonteCarlo' data column is required only if you are
                 doing Monte Carlo simulations for error analysis on fitted 
                 parameters. The Monte Carlo procedure requires an addi-
                 tional data column for temporary storage of data during 
                 the simulations.
        
              To the right of these data column allocations is the standard 
              deviation section. If you want a statistical analysis on the 
              fitted parameters then you need to supply DataFit with infor-
              mation on how much error is associated with the individual 
              data points. This is done by supplying standard deviations 
              for each individual f() data value. Standard deviation data 
              can be entered in one of three ways:
        
              1. If you don't know the standard deviation, then check the 
                 'Unknown' row by clicking on it with the mouse or pressing 
                 Enter while the cursor is there.
        
              2. If the standard deviation is constant for all data points, 
                 then check the centre row and fill in the value of the 
                 standard deviation.
        
              3. If the standard deviation varies for each data point, then 
                 check the third row, 'Column', and fill in a data table 
                 column number. Then go to the data table with AltD and 
                 fill in the standard deviations in each row of that col-
                 umn. Note that if the standard deviation is a simple 
                 function of the function value, or one of the independent 
                 variables, then you can use the F4 command in the data 
                 table to automatically enter the standard deviation into 
                 the table.
        
              Finally, you need to enter the names of any constants and 
              parameters which will be used in the function. Click or press 
              Enter on the left of the line to mark (*) the parameters 
              which will be varied during the fit. Any unmarked parameters 
              will be treated as simple constants. Then assign values for 
              each constant, and starting values for each variable parame-
              ter. (Linear Regression does not require starting estimates 
              for the variable parameters).
        
              You can place lower and/or upper limits on parameters to be 
              fitted. In the column where you enter the initial estimate of 
              the parameter values, follow the value with one or two num-
              bers separated by commas. But please take note: It is strong-
              ly recommended that you don't put limits on parameters unless 
              you really need to. Limits can have a destabilising effect on
              the fitting process, and may even result in failure to
              converge. Nelder & Mead will usually be the most stable
              method in these cases.

              Examples:
        
              [1.234,0,100   ] limits the value between 0 and 100, 
              [1.234,0       ] limits the value to >0,
              [1.234,,100    ] limits the value to <100.
                                    - 20 -





              IMPORTANT: Take care with data column assignments, as check-
              ing is not done to any great extent to determine conflicts. 
              If for example you allocated the 'Residuals' data column to 
              the same as the 'x' data column then the 'x' data will be 
              overwritten by the residuals.
        
        
        
        
        ================================================
        CHAPTER 20.  Alt-R  :  The REPORT setup screen
        ================================================
        
           The "Report" setup screen lets you control the format of the 
           output generated by the program. Specify page width in columns 
           for text output, left margin width, and whether to include the 
           list of data points in the output from function fitting.
        
           If data points are included in the output report then you can 
           choose any or all of errors (between fitted function and data), 
           percent errors, and standard deviations to be written alongside 
           each data point.
        
           Output always goes to the internal buffer for subsequent scroll-
           ing, but it can also be sent directly to printer and/or a disk 
           file. The internal buffer has a limited size, so very big prob-
           lems may need to send output to printer or disk.
        
           You can specify a format for representing numbers (natural, 
           scientific or auto) in the output report, plus decimal places (1 
           to 9), field width for lining up columns, and whether to show 
           trailing zeroes.
        
           Finally, the output report can include several lines of com-
           ments, either at the beginning or the end of the report.
        
        
        
        
        ===========================================
        CHAPTER 21.  F1 - Help
        ===========================================
        
           Type F1 while using DataFit to enter these Help screens. When 
           you are using the Help screens F1 takes you to the main Help 
           menu.
        
        
        




                                    - 21 -




        ===========================================
        CHAPTER 22.  F2 - Save work file
        ===========================================
        
           Type F2 while editing the text file to save it to disk. It is 
           good practice to do this regularly when entering data, and 
           especially just before starting to fit a function to the data.

           NOTE: The DataFit demo version will not save your data. This
                 section is included only for completeness.
        
        
        
        
        ===========================================
        CHAPTER 23.  F3 - Load a new work file
        ===========================================
        
           Type F3 to load a work file from disk, or to create a new file. 
           If the name you enter contains wildcard characters (eg. *.hls) 
           another window will be opened showing all files on disk which 
           match that filespec. Select one with the arrow keys and Enter, 
           or Esc to quit and return to the editor.
        
        
        
        
        ===========================================
        CHAPTER 24.  Alt-F3  -  Pick file
        ===========================================
        
           Type Alt-F3 to select from a list of files which have been 
           accessed during this work session. Move the cursor to select one 
           and type Enter to load it. To load a file not on the list, type 
           F3 or select the -- load file -- option at the bottom of the 
           list.
        
        
        
        
        =================================================
        CHAPTER 25.  F5 - Zoom the function screen width
        =================================================
        
           F5 toggles the zoom setting on the edit window between full size 
           and the "zoom-in" size when appropriate.
        
        
        




        

                                    - 22 -




        ===========================================
        CHAPTER 26.  F7 - Auto-scale axis values
        ===========================================
        
           Type F7 while you are editing the Graph data entry screen (Alt-
           G) to set sensible values for the axis ranges, divisions along 
           the axes, subdivisions, and number of decimal places for numeric 
           axis labels. When you press the F7 key the program scans through 
           the data table to find the minimum and maximum data values on 
           the x and y axes, then sets the graph axis values to appropriate 
           limits.
        
        
        
        
        ======================================
        CHAPTER 27.  F8 - Printing the graph
        ======================================
        
           Type F8 at any stage to enter the "Print Graph" setup screen. 
           This lets you specify printer type, output destination, hi/lo 
           resolution, and a "swap to disk" option to overcome certain 
           memory limitation problems.
        
           a) Printer:  A list of printers is shown at the left of the 
              setup screen. Select the one closest to yours by clicking on 
              it with the mouse or moving the cursor to it with the arrow 
              keys and pressing Enter.
        
           b) Output Port: Select the output port your printer is installed 
              on. This will normally be the default option. You can also 
              direct the graphics output to a disk file.
        
           c) Resolution: The default is hi-res. Select the low-res option 
              for rapid printing of draft-quality graphs. The resolution 
              option has no effect with PostScript printers.
        
           d) Swap to disk : Note the "swap out to disk" option at lower 
              right. High resolution printers such as LaserJets require a 
              lot of memory to compose the plot. EMS memory will be used if 
              it is available, but if not then you may not have enough RAM 
              available to complete the plot. In this case, check the 
              "swap" option, and this is what will happen: When you print, 
              DataFit first creates a temporary disk file which contains 
              primitive graphic instructions for the graph to be plotted. 
              Then it unloads all but a small kernel of itself to the hard 
              disk. Then it loads in a smaller program which reads the 
              temporary file and plots the graph using all the RAM that was 
              freed by swapping out DataFit. When printing is completed it 
              loads the DataFit program back in, to continue from where you 
              were.
        
              The "swap" option is NOT required for PostScript printers, 
              which use an entirely different method for generating the 

                                    - 23 -




              graphs, and which should not run out of memory.
        
           e) Font error: If you get a font file error while printing, the 
              program has failed to find a file called DEFFONT.GLF in the 
              directory containing the DataFit program. Check that it is 
              there, or de-select the "Use SansSerif/Helvetica font" option 
              in the "Graph" setup screen.
        
        
        
        
        ============================================
        CHAPTER 28.  F9  -  Select a new graph type
        ============================================
        
           DataFit lets you create several graph types from the function 
           fitting results. You can plot the fitted function with the 
           experimental data, or the residual errors vs either the function 
           response or any of the independent variables.
        
           Type F9 to open a window which lets you select from the avail-
           able types of graph.
        
        
        
        
        ===============================================
        CHAPTER 29.  Alt-F9  -  Select next graph type
        ===============================================
        
           DataFit lets you create several graph types from the function 
           fitting results. You can plot the fitted function with the 
           experimental data, or the residual errors vs either the function 
           response or any of the independent variables.
        
           Type Alt-F9 when using either the Graph setup screen (Alt-G) or 
           the Print Graph setup screen (F8) to change the current graph 
           type to the next available type.
        
        
        
        
        ====================================================
        CHAPTER 30.  Ctrl-F9  -  Select previous graph type
        ====================================================
        
           DataFit lets you create several graph types from the function 
           fitting results. You can plot the fitted function with the 
           experimental data, or the residual errors vs either the function 
           response or any of the independent variables.
        
           Type Ctrl-F9 when using either the Graph setup screen (Alt-G) or 
           the Print Graph setup screen (F8) to change the current graph 
           type to the previous available type.
        
                                    - 24 -




        ===========================================
        CHAPTER 31.  F10 - Menu
        ===========================================
        
           The F10 key transfers control to the main menu options displayed 
           on the top line of the screen. Select an option with the left 
           and right arrow keys and press Enter to activate it (or click on 
           an option with the mouse).
        
        
        




                                    - 25 -




        ******************************************************************
        
                          DataFit 1.0 -  A few case studies
        
        ******************************************************************
        
        
           Several demo data files have been provided on the distribution 
           disk to help you get started, and to act as case studies to 
           demonstrate some of the major features of DataFit. It is strong-
           ly recommended that you go through them all, as each has some 
           major features to demonstrate.
        
        
        
        ====================================================
        CASE STUDY 1 : DEMO1.FIT - Simple straight line fit
        ====================================================
        
           a) Introduction: This shows how to fit a simple straight line 
              through a set of data points. This is the simplest type of 
              problem to solve with DataFit, though you will also be shown 
              how to estimate standard deviations and confidence limits on 
              the fitted parameters - features not commonly available with 
              other straight line fitting programs.
        
           b) Loading: First type F3 to load in a data file. You will see a 
              small window showing the current DOS filespec (eg. *.FIT) for 
              the type of file to load from disk. Press Enter when *.FIT is 
              displayed, and a second window is opened to display all the 
              files ending in .FIT. Move the cursor to DEMO1.FIT, and press 
              Enter to load it.
        
           c) Description:  When loaded, the file contains a data list of 
              30 points, which was generated from a straight line with 
              normally-distributed random errors. The errors have a stand-
              ard deviation of 2. This is equivalent to measuring data 
              points which are expected to fall on a straight line, but 
              where the measurement error has a standard deviation of 2.
        
           d) General : The main screen shows the function, f(x)=a+b*x, and 
              that Linear Regression has been selected. The inactive 
              "Param" window shows that just one independent variable has 
              been defined (x) by having a data column defined for it, and 
              that these x-data are in column 1 of the data table. It also 
              shows that the function response data, f(x), are to be found 
              in column 2 of the data table.
        
              Additionally, data column 3 has been allocated to hold the 
              corresponding fitted values at each of the x-data values. 
              Data column 4 will hold the residuals of the fit (the differ-
              ences between the data and the fitted function), and data 
              column 5 has been allocated to be used as a temporary storage 
              column for when we come to do the Monte Carlo simulations 

                                    - 26 -




              later on.
        
              The standard deviation on the f(x) data values is known to be 
              2, and this is shown as such towards the centre-right of the 
              "Params" window.
        
              Finally, parameters a and b have been checked (marked) as 
              variables to be fitted. Linear regression does not require 
              starting estimates of the parameter values as it is not an 
              iterative procedure. So if you enter values for a and b they 
              will just be ignored.
        
           e) Fitting:  When the "Fit" window is active (indicated by a 
              double border, and the word "Fit" highlighted on the top 
              line) then just type AltF to start fitting. Or click on the 
              word "Fit" or any phrase starting with "AltF...".
        
              The screen changes to display the progress of the fit. It 
              will be fairly quick as this is a very simple problem to 
              solve. When done, a report is generated in the style speci-
              fied in the "Report" setup screen. In this case, you will see 
              the fitted parameter values, error estimates and confidence 
              limits on the fitted parameters, and a table showing fitted 
              vs actual function values at each value of the independent 
              variable x.
        
              Scroll through the output window to examine the solution. You 
              can also highlight a block to be printed or written to a disk 
              file.
        
           f) Graph the Fit: Type AltG or click on "Graph" to open the 
              graph setup screen. Sensible values have been supplied ready 
              to use, though you can change them if you wish.
        
              Type AltG again to display the graph on screen. The graph 
              page is shown scaled to the page dimensions defined in the 
              "Graph" setup screen, and positioned on the page as it will 
              be printed out.
        
              Note that the function itself is included in the graph title. 
              This is accomplished by including ~f in the title in the 
              Graph setup screen - described in more detail earlier in this 
              document. Similarly, the parameter values have been automati-
              cally entered  Type AltG to display the graph of the residu-
              als (or whichever type you selected), and Esc to return to 
              the " Graph" setup screen.
        
              As you get used to the program you may find it easier to 
              switch between graph types with the CtrlF9 and AltF9 keys. 
              Switch back to the graph of the fitted function in prepara-
              tion for printing it.
        
           g) Print graph:  Type F8 to enter the "Print Graph" setup 
              screen. Select a printer closest to yours from the list shown 
              at left. Select a printer output port if your printer is not 
                                    - 27 -




              installed as the default printer.
        
              Set the "swap to disk" option if necessary (see the F8-Print 
              Graph setup screen for more details). When all ready, type F8 
              again to start plotting.
        
           h) Monte Carlo:  The original Linear Regression fit will already 
              have returned standard deviations and confidence limits for 
              the fitted parameters, as standard deviations for the data 
              were specified (StdDev=2 for all data points in this case).
        
              There is a very important reason why the estimates may not be 
              accurate - the error estimation relies on the fact that the 
              data errors are indeed normally distributed (with StdDev=2 in 
              this case). It is possible that the errors on your data may 
              not be normally distributed, and may be skewed or biased in 
              some way. This is where Monte Carlo simulation can provide 
              useful additional information.
        
              Monte Carlo simulation was described earlier, but to recap 
              very briefly it simulates fitting the function to a large 
              number of sets of data points, each varying from your own 
              original data by the standard deviation which you specified 
              in the "Params" setup screen. Each fit returns a new set of 
              fitted parameters, and the Monte Carlo routine returns some 
              statistics about how those parameters varied.
        
              If the standard deviation/s of errors on your data (which you 
              supplied in "Params") were accurate, then Monte Carlo simula-
              tion will return similar values for the parameters and their 
              statistical deviations and correlations. If not, then the 
              Monte Carlo results will vary from the initial estimates of 
              these quantities, and you can ponder on the implications of 
              that for your own specific function fitting problem.
        
              By the way, a second reason for using Monte Carlo simulation 
              is in conjunction with the Nelder & Mead method. This method 
              does not return error estimates on fitted parameters, even if 
              standard deviations on the data points are available. So if 
              you are fitting with Nelder & Mead then Monte Carlo simula-
              tion is the only way to get error estimates on fitted parame-
              ters. See the next section (called "No StdDev?") for details 
              on how to do this.
        
              To do the Monte Carlo simulation first set the (*)Monte Carlo 
              option, then set the number of iterations you want to do. It 
              is strongly recommended that you do at least 100 iterations, 
              more if you have the time and patience. Then type AltF as 
              normal to begin fitting. The fit proceeds as before, but when 
              it is done a small window opens to show the progress of the 
              Monte Carlo iterations. When done the results are added to 
              the end of the output report.
        
              No StdDev? If you don't have any information on the standard 
              deviations of your data you can still estimate confidence 
                                    - 28 -




              limits etc. for the fitted parameters, though with some limi-
              tations. Do it like this. First fit the function using any of 
              the methods. At the end of the report, the standard deviation 
              between the fitted function and your data is listed. This can 
              be used as an approximation to the standard deviation on the 
              data points IF, AND ONLY IF, THE FITTED MODEL IS A GOOD ONE. 
              You must plot the fit against the data points and decide 
              whether the fitted function looks like a good representation 
              of the data points. If so, then enter the value of the stand-
              ard deviation between model and data into the "Params" setup 
              screen, and do the fit again.
        
           If you are using Linear Regression or Levenberg/Marquadt then 
           they will automatically report error estimates on fitted parame-
           ters once the data standard deviation has been entered in the 
           "Params" screen. If you are using Nelder & Mead then you will 
           have to use Monte Carlo simulation for error estimates on fitted 
           parameters.
        
           Note by the way that no additional information will be acquired 
           by using Monte Carlo simulation with Linear Regression or L/M 
           when the data standard deviations are estimated as explained in 
           this section. It may or may not be obvious, but if the standard 
           deviation between the original fitted model and the data is used 
           as the standard deviation for Monte Carlo simulations, then 
           Monte Carlo will return the same result as the original fit 
           (provided you do enough iterations to be statistically meaning-
           ful).



























                                    - 29 -




        ===================================================
        CASE STUDY 2 : DEMO2.FIT - Combination of 2 curves
        ===================================================
        
        
           a) Introduction: This demo shows how to fit two separate func-
              tions through different ranges of your data points. In this 
              case the function to be fitted is a straight line of negative 
              slope, or a logarithm curve, depending on which has the 
              greater value.
        
              The function is defined as f(x) = a+b*x max c*ln(x)-d. In 
              words this means f(x) at any x-value is either [a+b*x] or 
              [c*ln(x)-d)], depending on which has the greater value. We 
              need to find values for a, b, c, and d which provide the best 
              fit through the data points.
        
           b) Solving:  First type AltG twice to see what the data points 
              look like. Then Esc twice to return to the "Fit" setup 
              screen, and type AltF to start fitting with Levenberg/Mar-
              quadt. Then look at the graphs of fitted function and residu-
              als.
        
           c) More:   You can also fit separate function segments over 
              specific ordinate ranges using the logical functions  <  >  
              <>  =  <=  and <=. These let you fit piecewise smooth, dis-
              continuous functions. For example, say you want to fit a+b*x 
              for x<3, c*x^2 for 3<=x<6, and d+e*exp(x) for x>=6.

              Then... f(x)=(a+b*x)*(x<3) + (c*x^2)*((x>=3) and (x<6)) +
                           (d+e*exp(x))*(x>=6)

              A bit cumbersome perhaps, but it works. You will almost
              certainly have to use Nelder & Mead for these "strange"
              functions, though it would be worth giving Levenberg/ Mar-
              quadt a try just in case (especially if you have good start-
              ing estimates of the fitted parameters).


















                                    - 30 -




        =============================================
        CASE STUDY 3 : DEMO3.FIT - Selectivity curve
        =============================================
        
        
           a) Introduction: This is a simple demo illustrating the use of a 
              hyperbolic trig function (atanh) in a selectivity curve. It 
              also illustrates log axes on the graph.
        
           b) Solving:    Nelder & Mead is used for solving this example.
              Levenberg/ Marquadt gives a "singular matrix" error when 
              starting with a=1, b=1 and c=1, but Nelder & Mead is able to 
              find the solution from these starting estimates.










































                                    - 31 -




        ===========================================================
        CASE STUDY 4 : DEMO4.FIT - Manual adjustment of parameters
        ===========================================================
        
        
           a) Introduction: Demo 4 is an exponentially decaying sine wave, 
              which is very difficult to fit:  f(t) = sin(a+b*t)*exp(-c*t). 
              In addition, the starting estimates of a=1, b=1, c=1 are very 
              poor, and neither of the non-linear methods will find the 
              solution from these values.
        
           b) Solving:  This is a good chance to illustrate using the 
              fourth fitting method - Manual (Graphical) adjustment. Type 
              AltF to start fitting. The function is plotted with the (bad) 
              current estimates of parameters, and the data points. A table 
              at the top right shows a factor F and the current values of 
              the parameters. The Up/Down arrows move a marker to one of 
              the parameters, and pressing + - * / performs that operation 
              on the marked parameter (+ adds F to the parameter, - sub-
              tracts F, * multiplies and / divides the parameter by F). You 
              can change the value of F with the Left/Right arrow keys, for 
              Decrease/Increase.
        
              Each time you change the value of a parameter, the function 
              is replotted. So you can see immediately how each parameter 
              affects the function. With a bit of guesswork you should be 
              able to home in to the approximate solution. At that stage 
              you can exit with Esc, and switch to one of the non-linear 
              fitting methods.
        
              For this example, the solution occurs near a=0.125, b=1, 
              c=0.125. Change the parameter values to these values, and 
              then Esc back to the "Fit" screen. Now select Levenberg/ 
              Marquadt and fit with AltF to home in on the correct solu-
              tion.




















                                    - 32 -




        ==========================================================
        CASE STUDY 5 : DEMO5.FIT - "Dangerous" Linear Regressions
        ==========================================================
        
        
           a) Introduction: This case study is an illustration of the 
              dangers of using transformations to linearise non-linear 
              functions. The function to be fitted is: f(x) = ln(a+b*x 
              +c*x^2). It can be linearised into this form: exp(f(x)) = 
              a+b*x+c*x^2 which is linear in the parameters to be fitted 
              (a, b, c) once the function response has been transformed by 
              the exponential function. It can therefore be fitted using 
              Linear Regression, but this problem illustrates very well how 
              this can lead to "less than best" results.
        
           b) Solving:   First solve the problem with Linear Regression by 
              typing AltF. The fitted parameters are a=230.72, b=-39.8 35, 
              and c=5.5096. The output report indicates that the standard 
              deviation between model and data is 0.5678. Plot the fit with 
              AltG, and you will see that while the fit is good for higher 
              values of x, it is poor near x=0.
        
              Now type AltF or Esc to return to the "Fit" setup screen, 
              change the type of fit to Levenberg/Marquadt, and fit again 
              with AltF. Notice that as far as L/M is concerned the results 
              of the linear fit are so far from the solution that it can 
              not converge. Nelder & Mead finds the same problem.
        
              So, type AltP to go to the "Params" setup screen, and reset 
              the starting values to a=1, b=1 and c=2. Fit the function 
              using Levenberg/Marquadt. The results are now returned as 
              a=5.8459, b=1.3232, and c=3.9058.  The standard deviation 
              between model and data is now 0.1989. These results are 
              considerably different to the linear regression results, and 
              a plot of the fit with AltG shows that the fit is good for 
              the entire range of x values.
        
              Going back to the linear regression case, the error estimates 
              on the fitted parameters were based on the standard deviation 
              of 0.2. The data fitted by non-linear regression was trans-
              formed by the exponential function though, and this really 
              invalidates the standard deviation data. So the error esti-
              mates on the fitted parameters are incorrect (for Linear 
              Regression only). Here is a good chance to use Monte Carlo 
              simulation. Fit again by Linear Regression with Monte Carlo 
              simulation selected, for say 100 iterations. Now check the 
              error estimates on the fitted parameters. You will see at the 
              end of the output report that while the parameter values 
              differ substantially from the L/M results, they also have 
              very large associated standard deviations (errors), which 
              reconciles the two methods. Clearly Levenberg/Marquadt is the 
              much better method to use in this case.



                                    - 33 -




        ========================================================
        CASE STUDY 6 : FAMILY1.FIT - Fitting a family of curves
        ========================================================
        
        
           a) Introduction: This is an interesting example of fitting a 
              related family of curves through the data. In this case the 
              dependent data f() is a function of 2 independent variables x 
              and y. y takes on several discrete values only, and at each 
              y-value there are several values of x, representing a func-
              tion in x for each y-value.
        
              Go to the data table with AltD to see the values of x, y and 
              the function. You will see that y has the values 1, 2, 3, 4 
              and 5. Each y value has a different set of x-values.
        
           b) Solving: The solution is quite straightforward using Leven-
              berg/ Marquadt.
        
           c) Plotting:  Type AltG to see the "Graph" setup screen. Notice 
              right at the end of the screen is a line which lets you enter 
              several values of the 2nd independent variable, so that 
              several curves can be plotted. This line is always available 
              when more than one independent variable has been defined in 
              the "Params" setup screen. It is not restricted to parametric 
              curves only. Type AltG again to plot the fitted family of 
              curves.




























                                    - 34 -




        ========================================
        CASE STUDY 7 : GAUSS1.FIT - 2 Gaussians
        ========================================
        
        
           a) Introduction:  This case study is a nice example for using 
              Manual Adjustment of parameters in fitting a function with a 
              fairly large number of parameters. It also demonstrates how 
              to plot both the fitted function and its residuals on the 
              same page. The function is two Gaussians (normal distribu-
              tions):
        
              f(x) = a1*exp(-((x-b1)/c1)^2) + a2*exp (-((x-b2)/c2)^2)
        
           b) Solving:  First try estimating the approximate parameter 
              values by fitting with the Manual (graphical) Adjustment 
              method. Hint: the function is made up of two normal distribu-
              tions, each of which has a peak height, peak position along 
              x-axis, and width or spread. The peak height is determined by 
              parameter a, b controls the horizontal position of the peak 
              along the axis, and c controls the width.
        
              When you are getting close, type Esc to return to the "Fit" 
              screen, select Nelder & Mead, and fit. Then plot the fit with 
              AltG.






























                                    - 35 -




        ===================================================
        CASE STUDY 8 : PARAMET1.FIT - Parametric equations
        ===================================================
        
        
           a) Introduction: Here is a simple example of fitting parametric 
              equations to data. The method is not entirely trivial. Nor-
              mally, a two dimensional fit has one independent variable 
              (say x) and a dependent variable or response f(x). Parametric 
              equations in two dimensions require two independent variables 
              (say x and y), each of which varies with a third parameter, 
              usually t to indicate passage through time.
        
              The specific example given here is a simple ellipse centred 
              on (x,y) = (0,0). The parametric equations are:
        
              x=a*sin(t), y=b*cos(t)
        
           b) Solving:  So how do we set this up with DataFit? First go to 
              the "Params" screen. Now define both x and y as independent 
              variables and allocate their data columns (this is all al-
              ready done for you in PARAMET1.FIT). Make sure that a parame-
              ter called t is defined as a constant parameter. DataFit 
              insists that the parametric equation parameter is called t. 
              This needs to be assigned a data column, and an obvious spare 
              one which is not otherwise required for fitting parametric 
              equations is the "f()Data...[--]" data column. So assign this 
              the data column which holds the time or t data for the (x,y) 
              data pairs. Note that the actual values of t corresponding to 
              each (x,y) value must be entered into the data table, or an 
              error will result. Again, this is all done for you in PARA-
              MET1.FIT.
        
              Now go to the "Fit" screen with AltF. See how the parametric 
              equations are entered into the equation line:
        
              f(x,y) = [a*sin(t), b*cos(t)                   ]
        
              The x and y are assumed, and the individual equations are 
              separated by commas. In fact the commas are the trigger to 
              tell DataFit that parametric equations are being fitted. The 
              number of equations must match exactly the number of inde-
              pendent variable defined in "Params", and must be between 2 
              and 6.
        
              Now, all you need do is type AltF to do the fit. Then plot it 
              out with AltG.






        

                                    - 36 -




        ==============================================
        CASE STUDY 9 : POLAR1.FIT - Polar coordinates
        ==============================================
        
        
           a) Introduction: Here is an example of a normal simple fit, with 
              the result plotted in polar coordinates rather that the more 
              usual rectangular coordinates. The function to be fitted is 
              just a straight line, but when plotted in polar coordinates 
              it becomes a spiral:
        
              f(theta) = a+b*theta
        
           b) Solving:   Solve with Linear Regression, and plot with AltG. 
              Notice the "Graph" setup screen has the 'Polar Coords' option 
              set. This means that when plotting the function, the (x,y) 
              data are assumed to be in (theta,r) format, and are trans-
              formed before plotting onto the rectangular coords of the 
              graph:
        
              x=r*cos(theta), y=r*sin(theta)
        
           c) Plotting Range:  Note that when plotting with polar coordi-
              nate transformations the theta values (in this example) run 
              from 0 to 12.5 rad. By default the function plotting range 
              normally reflects the x-axis range: -8 to 8 in this case, so 
              the plotting range must be specified explicitly. To the right 
              of the "minimum value" and "maximum value" settings in the 
              "Graph" setup screen is a third column headed "Plotting 
              Range". Enter 0 to 12.5 to plot from theta = 0 radians to 
              12.5 radians.
        
        
        










        ==================================================================
                                   End of Document
        ==================================================================








                                    - 37 -





















