I have been looking in reference, but I cannot find anywhere in Minuit2Minimizer (or literally anywhere except TMinuit) how to access those parameters. I know I can use gMinuit, but gMinuit is only accessible after perorming a fit already…
The other thing is how to access gMinuit when using ROOT::Fit and Minuit2
currently you cannot modify the precision with the Minuit2Minimizer interface. I will add a SetPrecision method for the next release.
However, you are sure do you want to change this ? This is used mainly in the numerical derivative calculation. You might want to change the tolerance
(the API exists in Minuit2Minimizer).
If you are using Minuit2, no gMinuit global pointer exists.
currently you cannot modify the precision with the Minuit2Minimizer interface. I will add a SetPrecision method for the next release.
However, you are sure do you want to change this ? This is used mainly in the numerical derivative calculation. You might want to change the tolerance
(the API exists in Minuit2Minimizer).
[/quote]
The tolerance is one thing which indeed I do change. However, that is a good question - I heard that precision changes helps to avoid too small parameter changes, that’s why I try it. I attach log files from simple examples. Both first do fit with all parameters fixed, to gain access to gMinuit, than release parameters 3, 4, 9, 10. prec_change changes the precision:
and no_prec_change has those gMinuit lines commented out. Than I repeat the fit. With prec_change fit coverges, without it does not. Maybe it’s just kind of a simple change of a condition, when Minuit decides it has converged, however, the final result: converged or not converged, changes.
Additionally I attach minuit and minuit2 logs. Exactly the same fit with same parameters (no precision change), but minuit converges while minuit2 does not (minuit and minuit2 files). Maybe it is as it should be and maybe these logs could help to fix/improve something.
So it is not possible to change precision with minuit2?
if your minimization function is calculated only at the 10^-4 level of precision then you need to change the fEpsmac values to avoid having a numerical error in calculating the derivative.
With Minuit2 you can change the precision using the MnMachinePrecision class, but as I said I need to add a SetPrecision method in the Minimizer interface in order to use it when fitting using the ROOT::Fit classes. This will be available also when using TMinuit as minimizer in ROOT::Fit, so you will not need to do the workaround with gMinuit.
[quote=“moneta”]Hi,
if your minimization function is calculated only at the 10^-4 level of precision then you need to change the fEpsmac values to avoid having a numerical error in calculating the derivative.
[/quote]
However, I calculate the derivative manually, so I am not sure if this applies…
I understand. I am waiting
However, one another question emerged. I have following situation (no matter why at this moment, although it is strange):
CHECK OF GRADIENT CALCULATION IN FCN
PARAMETER G(IN FCN) G(MINUIT) DG(MINUIT) AGREEMENT
3 dx 3.8272e+00 4.9834e+00 8.5927e+00 GOOD
4 dy 4.4494e+00 6.5146e+00 1.2660e+01 GOOD
10 scale -4.0532e+00 -5.0357e+00 9.4038e-01 BAD
11 bg 8.0316e-01 8.0316e-01 4.6405e+00 GOOD
MINUIT DOES NOT ACCEPT DERIVATIVE CALCULATIONS BY FCN
TO FORCE ACCEPTANCE, ENTER *SET GRAD 1*
is it possible to SET GRAD 1 with ROOT::Fit classes?
Thank you for the logs, but what is the difference between minuit.txt and the log with no precision changes ? One converges and the other not ?
The log of minuit2 looks to me similar to the one failings (I get the same errors and same fcn value at the end).
The precision is also used in the line search algorithm, so maybe this is relevant for you. If you increase precision you should be careful not to use tolerance too small otherwise you will get messages like “machine accuracy limits further improvement”
OK, maybe I did a little bit of a mess. prec_change.txt should be compared with no_prec_change.txt. Both are Minuit, but one changes the precision before the second attempt and one does not. The one without the change does not converge, the one with precision change converges (and chi2 and final parameters differ slightly.
minuit.txt shold be compared with minuit2.txt. These are slightly different fits than prec_change.txt and no_prec_change.txt. minuit.txt is done with Minuit and minuit2.txt is done with Minuit2. Initial parameters are exacly the same - the only change in the code is a change from Minuit to Minuit2. However, Minuit converges and Minuit2 does not converge. That comparision has nothing to do with precision changes - just a sample where one minimizer converges and other not. I am not sure if it is what is expected.