Levenberg-Marquardt method

Hi

I need to use this method for a function which I want to introduce.
I try with the fit panel, no chance for both cases, I cannot introduce the user function and when I select GSL + Levenberg-Marquardt method, and then click on fit, the process stays block so I have to re-boot.
Do you have an example of a script or a better description of how to use the FitPanel functionalities?
This will help me.
Thank y very much
Sor

Is there any news on my question? Thanks Sor

Hi,

To use this method you need to have first MathMore installed in the system.
You can check this by typing

root-config --has-mathmore

The answer must be yes

Then the method works hen you are doing a least-square (chi-square) fit, for example when fitting an histogram or a Graph.
From the command line you can select the method by doing before fitting

ROOT::Math::MinimizerOptions::SetDefaultMinimizer("GSLMultiFit");

Here is a complete but simple example in the case of an histogram:

{
TH1D * h1 = new TH1D("h1","h1",100,-5,5);
h1->FillRandom("gaus");
ROOT::Math::MinimizerOptions::SetDefaultMinimizer("GSLMultiFit");
h1->Fit("gaus");
}

In the case of the FitPanel you can select in the Minimisation tab. It works for me, so if it is strange it is halting your system. You should try to use from a macro. In case please send me your fitting object and function (histogram or graph).

If you want to use the algorithm to minimise a user-defined least-square function, it is possible but in that case the least square function must implement the ROOT::Math::FitMethodFunction interface.

Best Regards

Lorenzo

Hi Lorentzo

It is working, many thanks.
I have few more questions.
1)I am working on Windows 64 Entreprise 7.
Maybe is a silly question but how do i run the command
root-config --has-mathmore
Obviously the installation on Windows has it because
ROOT::Math::MinimizerOptions::SetDefaultMinimizer(“GSLMultiFit”); worked.

On MAC it is working from the terminal but on Windows I didn’t managed to make it run.

2)how can I make 100 times iteration and printout the results of the parameters.
Many thanks
Sor

Hi,

I don’t know if 'root-config` is available on Windows. But a simple check could be also this one, from the ROOT prompt:

if no error is printed and it returns zero then it means the library exists.

You can stop the Minimiser after a certain number of interactions, inter, by doing:

ROOT::Math::MinimizerOptions::SetDefaultMaxIterations(niter)

Lorenzo

Thanks it is working perfectly.
One more question, how can i see how was implemented the method, is the equation the “damped version”, and if so what is the default value?
Sor

Hi,

What do you want to know exactly ? The code where the method is implemented is in GSL, the function used is gnu.org/software/gsl/manual … erivatives

Lorenzo

I mean the dampered version of the equation, see the following link
en.wikipedia.org/wiki/Levenberg … _algorithm

which generally is more difficult to converge.
Anyhow for the moment this method is working fine, many thanks
Sor

If you want to know more about the algorithm, you can look at the reference given in the GSL documentation,
J.J. Moré, The Levenberg-Marquardt Algorithm: Implementation and Theory, Lecture Notes in Mathematics, v630 (1978), ed G. Watson.

Lorenzo