How to change the Fit minimizer algorithm

Hello,
I’m trying to use simplex to fit a TH1D histogram.
I did use the command at the beginning of my macro:
ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit", "Simplex");
to change the default algorithm to Simplex, but the fit still says that it’s using MIGRAD.
How do I correct this?

Thank you very much,
Hoa.


Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.24/00
Platform: Not Provided
Compiler: Not Provided


Hi @LongHoa ,

I think we need @moneta 's help, let’s ping him.

Cheers,
Enrico

1 Like

Hello,
If you are doing it before fitting it should work and use Simplex. Can you please get the FitResult , using option “S” and then print it,

auto r = h1->Fit(function,"S");
r->Print();

Lorenzo

Hi @moneta ,

Printing the fit result gives me:

****************************************
         Invalid FitResult  (status = 4 )
****************************************
Minimizer is Minuit / MigradImproved
Chi2                      =      3342.49
NDf                       =           14
Edm                       =      805.169
NCalls                    =          932
p0                        =      29.3491   +/-   1.49009e-06 
p1                        =      3.56235   +/-   0.000171586 
p2                        =       344330   +/-   1397.5      
p3                        =      10.9942   +/-   3.60064e-05 
p4                        =            5   +/-   0.0012021    	 (limited)
p5                        =      1.00004   +/-   0.0062542    	 (limited)

It still shows Migrad instead of Simplex.

Here are the codes I’m using, including a histogram generator[1] and fitter[2], together with a function declarations[3].
I the fitter, I set the default minimizer and algorithm to minuit and simplex at line 65, right at the start of the main code. Am I doing anything wrong?

Thank you,
Hoa.

[1] hit_generator_forum.C (1.5 KB)
[2] spectrum_fitter_forum.C (6.1 KB)
[3] function_forum.h (6.6 KB)

Hi,

You are using option "M", which is a special algorithm used after minimization to check if the minimum is really a global one. Unfortunately this algorithm does not work very well, I would eventually try in a second fit If you remove that option you should see the result of Simplex

Lorenzo

1 Like

Hi @moneta

Thank you very much. Removing the “M” option does the trick.

Hoa.