myfitter is hosted by Hepforge, IPPP Durham

3.2 Minimising the chi-square 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 non-zero value otherwise. After a successful fit, the parameters of the model object (as returned by the Model::parameter method) are the best-fit parameters, the observables (as returned by the Model::observable method) are the values of the observables at the best-fit point and the chi-square value (as returned by Model::chisquare()) is set to the minimal chi-square 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 chi-square 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 chi-square 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 chi-square value and returns zero if the calculation was successful and a non-zero value otherwise.

In myFitter the minimisation of the chi-square function is done with the algorithms for multi-dimensional 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 chi-square 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 chi-square function drops below minimizer_precision() the minimisation is considered successful. Note that, for the purpose of computing the gradient, the derivatives of the chi-square 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 chi-square 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 semi-finite intervals to the real axis. This way, the GSL minimiser always “sees” a chi-square function of unbounded parameters. However, if minimum of the chi-square 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 non-zero 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.