Home | News | Documentation | Download

Fit with variables varying by integer steps


In order to find the best limits to use for fitting one histogram, I’d like to make a minimization of the chi^2 while the limit bins vary.
So I tried to put the limit bins as parameters of my FCN in Minuit. My FCN works very well. However, the Minuit minimization doesn’t work since I don’t know how to tell Minuit that some parameters in my FCN (the bins’ numbers) are integer.
Hence, it starts to move the bins’ numbers but after one step, the step sizes become less than 1 and the bins don’t change anymore.

This problem is, for sure, linked to the fact that the Minuit step size are not integer and vary.
Does someone know how to tell Minuit to keep integer values for some of the parameters ? Or do you know a better way to do what I want ? (except doing the minimization by varying the limits and finding the minimum chi^2 by myself…)

Thank you in advance, Olivier.


Minuit does not work with integer variables and non-smooth functions, since needs to be able to evaluate the function derivatives.

It might work if you use a simulated annealing minimizer, which in ROOT is provided by the class ROOT::Math::GSLSimAnnealing,

see project-mathlibs.web.cern.ch/pro … aling.html

Best Regards


It might work if you use a simulated annealing minimizer, which in ROOT is >provided by the class ROOT::Math::GSLSimAnnealing,

Thank you. It seems to be what I am looking for. Is there any tutorial ? I don’t get how to get a FuncIter function from a FCN…

Not yet, I will make one tomorrow and send to you,


Thank you very much !

Hi ,

attached is a simple example of using simulated annealing to find a global minimum of a function.

You can try in your case, I hope it will work and I will be grateful for any feedback.
However, I have maybe spotted some potential problems with the released version in 5.17.04. For example, currently not all the control parameters of the siulated annealing are exposed to the user, and the metric funciton is probably not correct. I am going to fix this later on in the trunk ROOT version in svn.

Best Regards

testSimAnnealing.C (1.33 KB)

Hi Lorenzo,

I have a similar problem as the OP. I tried using your code and everything worked fine. Now I want to retrieve the errors of the estimated parameters but the program crashes. Why is this happening? Is it that errors are not defined for this minimizer (although here it says that GSLSimAnMinimizer inherits the Errors method from Minimizer)?.
To reproduce the error I only need to add

const double * xerr = siman.Errors();

to your code. Any help is very appreciated.

Thank you!

Best regards,

ROOT Version: 6.22/01
OS: macOS Catalina (tried with lxplus as well)

Hi Francisco,

The GSLSimAnMinimizer does not implement the computation of errors , since the minimiser does not use any derivatives of the objective functions.
I should add an error message in the code to avoid this crash.

The way to compute errors in that case is if you can try running one of the other minimizer from the minimum point, or if you cannot use a different procedure like bootstrapping, i.e. generate different datasets similar to the one you have and find the optimal parameters for each one of them. From the variation obtained you can estimate then the parameter errors.

Best regards


1 Like

Hi Lorenzo,

Thank you very much for your answer.

I was hoping it could :frowning: . However, the reason you mention makes a lot of sense.

I tried running Minuit but since I have one parameter with fixed step size, sometimes it fails to converge.
Also, I am afraid I cannot use the bootstrapping method, since I cannot generate similar datasets to this one…

Thank you for your help!