Function fitting


gd supports fitting of functions to 1-dimensional data.
Data to be fitted are marked by an extra F in the H:-lines of the input files:

H: x       y,f      d
   ...     ...     ...
   x-data  y-data  y-errors

Note that by default the data are fitted as presented,
that is, for log plots the log10()-values of the data are fitted.
For example a polynomial fit in a plot with logarithmic x axis is:

   y = p1 + p2 * log10(x) + p3 * (log10(x))**2 ...

This behaviour can be changed with the GMODE command:

   GMODE/FIT(DATA)   fit the original data
   GMODE/FIT(REPR)   fit the data as presented (default)

The y-error bars of the input data are taken into account as weights
for chi-square evaluation.
Unsymmetrical vertical error bars are averaged and symmetrized.
Wherever possible you should provide error values with the y-data.
The input errors will affect the errors of fit parameters.
If no error values are given they are estimated from the chi-square value
so that a chi-square of 1 would result.

Fitting can be accomplished in two different ways:

1. Automatic polynomial fits

This is a fast way of fitting because it is a straightforward  procedure
which can be performed analytically. No extra user intervention is required.
You specify the order of the polynomial with the display parameter POLYNOMIAL().
On display, the data together with the fitted curve and, with the optional
display parameter CONFIDENCE(), two additional
curves outlining the specified confidence interval are drawn.
After display, the polynomial coefficients and their errors as well as
additional statistical information (chi-square etc.) are listed in the shell
window which runs gd.
More than one data block and more than one column per data block can be processed.
A typical command sequence would look like:

   GREAD file.gd                 read the data
   GDISP / POLY(3) CONF(0.683)   display data, fit a 3rd order polynomial, draw confidence limit
   GCOPY p65gps                  copy the picture to a printer of your choice

2. Separate fit package

Nonlinear and user-specified functions, function stacking and sophisticated fit parameter
handling require a dedicated fit package, derived
from GSIs MVS-based listmode processing environment SATAN.
In contrast to the automatic fitting described above you will need
to control the different steps of function fitting by a few dedicated
commands (starting with the letter F). The fitting procedure
is restricted to a single y-column in the input file.
Note that you need to switch from automatic polynomial fitting to "controlled" fitting
by specifying a polynomial degree < 0. A typical command sequence looks like:

   GREAD file.gd      read the data
   GDISP / POLY(-1)   display data, suppress automatic fitting
   FPEAKS 2           choose a fit function (2 gaussian peaks)
   FIT                fit the data
   FRES/GRAPHIC       list results (on the plot)
   FDISP/CONF(0.683)  display final fit curve, with confidence limits
   GCOPY p65gps       copy the picture to a printer of your choice

See the description of the fit package for more details.