# Chi2 minimization without error calculation

Hi,

Is it possible to instruct MINUIT to find the minimum chi2 (or the maximum log-likelihood) without calculating the parameter errors? I am invoking MIGRAD, but the manual explicitly says that errors are calculated:

Causes minimization of the function by the method of Migrad, the most efficient and complete single method, recommended for general functions (see also MINImize). The minimization produces as a by-product the error matrix of the parameters, which is usually reliable unless warning messages are produced.[/code]

I am interested in histogramming the maximum log-likelihood distribution for a very large number of fits. The parameter errors are not interesting in my case and I am trying to speed up the process.

Many thanks,

–Christos

Hi,

Migrad needs the Hessian matrix (second derivatives) for finding the function minimum. The covariance matrix is easily obtained by inverting the Hessian matrix at the minimum. You can try by setting strategy=0 (“SET STRATEGY 0”) In this case a precise calculation of the Hessian matrix is not done at the end of the minimization and only an approximated Hessian is used. However, by calculating the full Hessian, Migrad has better convergence properties and you risk to have fits not converging to the desired tolerance value.

Normally the best way to speedup your fits is by optimizing your model function evaluation.

Best Regards

Lorenzo

Hi Lorenzo,

Yeah, I already tried setting the strategy to 0. The speed improvement was not that spectacular.

I was considering testing a different minimizer, just in case MIGRAD is just too precise for this task. Are there any other options I can use with ROOT?

I already optimized the obvious things. Maybe I need to do a taylor-expansion of the log-likelihood to see if that makes a big difference. I didn’t get to it yet.

Thanks, C.

Hi,

you can try using Fumili, it might be slighter faster, but again if you are far away from the solution, it could have more failures.
If your function is linear (or can be made for example linear in the log scale) then you can use also the linear fitter which provides a direct solution and this can be much faster. Otherwise Minuit is already a good and very efficient minimizers and it is difficult to do better.
You can try also to supply the derivatives if you can calculate more efficiently than the numerical calculations done in Minuit.

Otherwise you should then run in parallel using multiple threads or processes. You can split your fits or the likelihood sum or using a paralell version of Minuit2 capable of running on multi-threads (with openMP ) or multi-processes with MPI

Cheers

Lorenzo

Dear Lorenzo.

Thanks for your response. These are good hints, and I will investigate.

Best, C.

Dear Lorenzo,

This is not directly related to the question asked in this thread but it has to do with the following comment.

The following page mentions how to build a parallel version of Minuit2.
lcgapp.cern.ch/project/cls/work- … otes2.html

It says that we should set the environment variables USE_PARALLEL_MINUIT2 and USE_OPENMP before compiling ROOT with Minuit2.

But how can we use this build to utilize a muticore CPU for parallel minimization? Is there any example code in ROOT?

Thank You,
Tarak.

You can use whatever example of Fitting or minimization. For fitting you need to set Minuit2 as default minimizer:

``ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit2")``

And then the fitting will be automatically computed using the available cores

Lorenzo

Hi Lorenzo,

[quote=“moneta”]You can use whatever example of Fitting or minimization. For fitting you need to set Minuit2 as default minimizer:

``ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit2")``

And then the fitting will be automatically computed using the available cores
Lorenzo[/quote]

Is that all that needs to be done? I tried it, but it appears that with both MIGRAD and SIMPLEX minimization only one core is used. Do I need to setup and configure OPENMPI to use multiple cores? Or set some environment variables? I am compiling a standalone C++ application with ROOT+Minuit2 libraries.

Tarak.

As you mentioned before you need to rebuild Minuit2 from source after having set the following env variables:
USE_PARALLEL_MINUIT2 and USE_OPENMP.
This makes a Minuit2 library version which can be used with OpenMP.

So you need to download a source version of ROOT and before building ROOT do:

``````./configure --enable-minuit2
export USE_PARALLEL_MINUIT2=1
export USE_OPENMP=1
make``````

Note that openMMP is supported only with g++ version >= 4.2

Afterwards you can run your fitting application. The number of cores is controlled by the env variable