Prev Next Title Contents

THE GENERAL FITTER


In addition to the line-fitting module presented in the previous chapter, Gifa contains a generic, multipurpose, general minimiser. This module is able to minimise any function on a set of parameters. The minimiser works with the Powell method, which does not require derivative expression. It relies on a two steps minimisation which are controlled with ITER (Number of iteration in the outer loop) and MINITER (Number of iteration in the inner loop, execute for each axis, and for each outer iteration). Values of 10 for both control seems to be Ok. note that if only 1 parameter is to be optimised, only one outer loop is needed, then ITER is not used, MINITER is then the only relevant control. This explains also why the minimisation is much faster when only one parameter is to be minimised.

Functions to be minimised are written in the Gifa language and should simply be a regular Gifa expression.

The general minimiser comes in two flavours: MINIMIZE and FITGENE. MINIMIZE is a general minimiser, FITGENE is a general Fitter,.

MINIMIZE

This command takes a given expression and try to minimise it's value by varying some free parameters in it. The expression is given in Gifa syntax, and the free parameters are the global user variables $P1, $P2, etc...

You give to the command i) the expression to be minimised (as a string) ii) the number of free parameters to be adapted (called $P1, $P2, ...)

The command returns the minimum found (also available in $chi2)

e.g.

MINIMIZE 'abs(sin($p1)/$p1 - 0.5)' 1

returns

MINIMIZE Final Value : .27782464E-04

and p1 is set equal to 1.89543

This tells you that the function sin(x)/x is equal to 0.5 when x = 1.89543

Note that $P1, $P2,.. are global user variables. If they exist when the command is called, their values will be used as initial trials, if they does not exist, they are created and set to 1.0

FITGENE, showexp

This command is similar to the previous one, but permit to fit a given function to a set of experimental points Xi, Yi. Yi is taken to be the regular 1D buffer, Xi is obtained from the TAB buffer (see Buffers). This permits to fit an arbitrary function through any set of X,Y points.

You give to the command i) the expression of the function to be fitted (as a string) the running parameter is called $X ii) the number of free parameters to be adapted (called $P1, $P2, ...)

FITGENE then minimises a chi2 and returns its value after fitting (also available in $chi2)

e.g.

FITGENE '$p1 + $p2 * $x' 2

realises a linear fit of the data points.

The standard macro showexp permits to draw the given expression to check the quality of the fit :

showexp '$p1 + $p2 * $x'

will actually draw the fitted line.

Again, the $P1, $P2.. $Pi are global user variables that can be freely used after the fit.

Note that the expression to be fitted is a generic string, and can for instance, very well be held in a (global) variable :

set exp := '$p1*exp(-$p2*$x)'

fitgene $exp 2

showexp $exp

will fit T2-like data-sets


Prev Next Title Contents