
3.2 Minimising the chisquare Function
Once the likelihood component of your Fitter object is properly
initialised, you can fit model objects to the data with the methods
int Fitter::local_fit(Model& model)
int Fitter::global_fit(Model& model)
These methods return zero if the fit was successful and a nonzero
value otherwise. After a successful fit, the parameters of the
model object (as returned by the Model::parameter
method) are the bestfit parameters, the observables
(as returned by the Model::observable method) are the
values of the observables at the bestfit point and
the chisquare value (as returned by Model::chisquare() ) is
set to the minimal chisquare value. The difference between the two methods
is that local_fit uses the current parameter values of the model
object as starting point for the chisquare minimisation while
global_fit looks through the dictionary of the model object
(generated by previous calls to Model::scan ) to find the best
starting point. To only calculate the chisquare value for the current
parameter values (without any minimisation) you can use the method
int Fitter::calc(Model& model)
It sets model.chisquare() to the computed chisquare value
and returns zero if the calculation was successful and a nonzero value
otherwise.
In myFitter the minimisation of the chisquare function is done with
the algorithms for multidimensional minimisation provided by the
GNU Scientific Library (GSL).
You can change the parameters for these algorithms or indeed the algorithm
itself with several Fitter methods:
const gsl_multimin_fdfminimizer_type* minimizer() void minimizer(const gsl_multimin_fdfminimizer_type* t)  These methods return or set the GSL minimiser used for chisquare
minimisations. Detailed information on the available algorithms can
be found in the GSL documentation.
The default value is
gsl_multimin_fdfminimizer_conjugate_fr and
you will probably want to use that one or
gsl_multimin_fdfminimizer_vector_bfgs2 .
int minimizer_verbosity() void minimizer_verbosity(int n)  These methods return or set the verbosity level for minimisations. The
default value is zero, in which case no information is displayed
during a minimisation. Values of 1 to 3 will print increasing amounts
of information to
std::cout .
double minimizer_step_width() void minimizer_step_width(double s)  These methods return or set the initial step width of the minimiser. More
information can be found in the
GSL documentation.
The default setting is 0.01.
double minimizer_tolerance() void minimizer_tolerance(double t)  These methods return or set the tolerance of the minimiser. More
information can be found in the
GSL documentation.
The default setting is 0.1.
double minimizer_precision() void minimizer_precision(double p)  These methods return or set the precision of the minimiser. If the
norm of the gradient of the chisquare function drops below
minimizer_precision() the minimisation is considered successful.
Note that, for the purpose of computing the gradient, the derivatives
of the chisquare function with respect to the parameters are multiplied
by the scale of the corresponding parameter (as configured with
the Model::scale method). Thus, unreasonably small values for scales
of the parameters can lead to a premature termination of the minimisation.
The default setting is 0.001.
int minimizer_iterations() void minimizer_iterations(int i)  These methods return or set the maximum number of iterations for a
chisquare minimisation. If the maximum number of iterations is
exceeded, the minimisation is aborted and the status
GSL_EMAXITER (defined in the header gsl/gsl_errno.h)
is returned. The default setting is 200.
double minimizer_snap_distance() void minimizer_snap_distance(double d)  The GSL algorithms for minimisation can not handle the case of bounded
parameters. Thus myFitter internally applies smooth invertible
functions to the parameters which map finite or semifinite intervals
to the real axis. This way, the GSL minimiser always “sees” a
chisquare function of unbounded parameters. However, if minimum of the
chisquare function is close to or even on the border of a parameter's
allowed range, the minimisation will fail because the applied mapping
is singular. In this case, the parameter in question should be fixed to
its upper or lower limit and the minimisation should be done with one
free parameter less. If you set
minimiser_snap_distance() to a
nonzero value, myFitter will do this automatically when,
during a minimisation, a parameter gets closer than
minimiser_snap_distance()* s to its upper or lower bound.
Here, s is the parameter's scale as configured with the
Model::scale method. The default setting is 0.1.
