Minimization in PyROOT

Dear Users,

I am fairly new to ROOT and wanted to minimise a function using the PyROOT framework, but don’t really know where to begin. I have stumped upon the TMinuit and Math.Minimizer classes, but there are very few tutorials available (or at least I haven’t found them), and I’m not sure if one has better performance / is more commonly used today. Any hints and recommendations would be appreciated!

${ROOTSYS}/tutorials/fit/

Hi,
The recommended way to minimise a function is to use the ROOT.Math.Minimizer class. There is this tutorial, ROOT: tutorials/fit/NumericalMinimization.C File Reference, but it is in C++. If you have issues translating it in Python, please let me know, I can provide that example also in Python

Lorenzo

Dear @moneta, thanks for your hints. An example in python would be in fact very useful, as I am not very acquainted with C++. Many thanks in advance!

Hi,
Here is the Python tutorial for minimising a function:

It will be soon merged into ROOT master

Lorenzo

Thank you very very much for the tutorial! :slight_smile:

Hi @moneta, I was looking at your code, and wanted to point out two possible typos:
(1) In line 37 I think you mean MinimizerName
(2) In line 76 you perhaps mean if ( ret and abs(minimizer.MinValue()-f(xs)) < 1.E-4 ) :, so that you take the difference between the two minimum values instead of the values themselves, no?

Thank you very much for the corrections. I will include in the open PR for the tutorial,

Cheers

Lorenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.