Minimization example with pyRoot

Hello,
I was wondering if there is any example of minimization
(e.g. using TMinuit) using pyRoot. I tried looking for it in
$ROOTSYS/tutorial and test, but I didn’t find anything like this.
Thank you very much,

davide

Davide,

please find attached an example that I received a while ago from another user. Not all usages of arrays are necessary, and note that you can pass doubles by reference, as long as you make sure that the python side doubles are unique (init them with different values, for example).

HTH,
Wim
fittest.py (2.31 KB)

Wim,
thank you very much! in my code I was messing up
something with passing to Minuit the required arrays.
This is exactly what I need :slight_smile:)
Thanks,

davide

Now, I found there are some errors even in this example.
After the mnstat call, if you print out the value of icstat,
it is 1985. The correct one should be 3 in convergence.

So I wonder, is it a bug that means we could not use this
quantity reliably? How to solve this problem?

[quote=“wlav”]Davide,

please find attached an example that I received a while ago from another user. Not all usages of arrays are necessary, and note that you can pass doubles by reference, as long as you make sure that the python side doubles are unique (init them with different values, for example).

HTH,
Wim[/quote]

Hi,

thanks for catching. Is a bug: although long& works, int& does not. Python internally uses a long in its int objects, so passing through long& is safe, through int& not. To be fixed …

Cheers,
Wim