# General Minuit2 Minimization interface questions

I have a few questions regarding the Minuit2 minimization package via the ROOT Minimization interface. I apologize if they are very naive. I’m just starting to learn how to use the interface:

1. Where can I a more detailed explanation of the output from Minuit2 when using the Minimization interface? I typically set the print level to 3.

2. What are the meanings of the different variables passed to the Scan method and is there a preferred way to call the Scan method?

3. When using Minuit2 to minimize a Log Likelihood function, what is the standard (or best) way to make a LogL vs parameter value plot?

When using printlevel=3 the result of each iteration is printed. You have :

FVAL : function value for that iteration
EDM: expected distance from the minimum. This is the quantity used for the convergence of the iteration. When is smaller than tolerance the minimisation is stopped
Nfcn :: number of function calls
Error matrix change: how much the error matrix changes in the iteration
Parameters: value of the fit parameters (variables of the function to be minimised). The user value is printed (Minuit applies internally a transformation)

The signature is

```bool Scan(unsigned int i , unsigned int & nstep , double * x , double * y , double xmin , double xmax); ```
i is the parameter index
nstep: is the number of points to scan
x is the returned array with the scanned x points
y is the array with the returned y values
xmin is an optional parameter with the minimum parameter value to scan
xmax is the maximum parameter value.
In case xmim and xmax are not given the scan will be done in +/- 2 error on the parameter
Sorry if the documentation is not clear on this. I will fix it.

You can call Scan after having done the minimisation. For example you can do this to scan the parameter ipar

``````int npoints = 20;
std::vector<double> x(20);
std::vector<double> y(20);

minimizer->Scan( ipar, npoints, &x[0], &y[0] );
TGraph * g = new TGraph(points, &x[0], &y[0] );
g->Draw(); ``````

If you still have problems using Scan, I can send you an example

Best Regards

Lorenzo

Hi Lorenzo,

Thank you very much for your response. If I understand Scan correctly, it will scan parameter number ipar near its minimum a total of npoints away and return those corresponding parameter values and LogLikelihood values (x, and y arrays respectively). Is this right?

I seem to be getting an error when I implement the function call of Scan. I have done almost exactly as you have suggested:

[code]
int npoints = 20;
std::vector vC_rec_x(20);
std::vector vC_rec_y(20);

minim -> Scan( 0, npoints, &vC_rec_x[0], &vC_rec_y[0] );
TGraph *gScan = new TGraph(npoints, &vC_rec_x[0], &vC_rec_y[0] );
gScan -> SetName(“gScan”);
gScan -> Draw();[/code]

However, I get the following error:

error: no matching function for call to ‘ROOT::Math::Minimizer::Scan(int, int&, double*, double*)’
root/Math/Minimizer.h:286: note: candidates are: virtual bool ROOT::Math::Minimizer::Scan(unsigned int, unsigned int&, double*, double*, double, double)

Hi,

Try by declaring points as “unsigned int” instead of “int”. Here is the correct code:

``````  unsigned int npoints = 20;
std::vector<double> vC_rec_x(20);
std::vector<double> vC_rec_y(20);

minim -> Scan( 0, npoints, &vC_rec_x[0], &vC_rec_y[0] );
TGraph *gScan = new TGraph(npoints, &vC_rec_x[0], &vC_rec_y[0] );
gScan -> SetName("gScan");
gScan -> Draw();``````

Lorenzo

Hi Lorenzo,

Thank you very much for your reply. It worked like a charm!

Is my understanding of Scan correct?

Lorenzo

Hi Lorenzo,

Thanks for explaining everything. One last question about the output of Minuit2. What does

Minuit2Minimizer : Valid minimum - status = 0

mean? Are there different values for the status flags that correspond to different statuses with Minuit2?

Hi,

It is documented in root.cern.ch/root/html/ROOT__Min … r:Minimize

``````   status = 1    : Covariance was made pos defined
status = 2    : Hesse is invalid
status = 3    : Edm is above max
status = 4    : Reached call limit
status = 5    : Any other failure
``````

status = 0 means that no problem has been detected and the minimum is then valid.

Lorenzo

1 Like

Hi Lorenzo,

Thank you very much for the link and explanation!

@moneta This is very helpful. However, I have a simple question as the documentation is brief to the point of being a bit confusing. What does “Covariance was made pos defined” mean? Specifically, what does the phrase “was made pos defined” mean? I would assume this means that it was forced to be positive definite, so is “defined” a typo? Or am I misunderstanding what is trying to be conveyed.

Hi,

Sorry yes it is a typo. It means the matrix was forced to be positive definite, by adding an extra positive value to the diagonal. I will fix the comment in the code