TFitter Minuit Execute Command TypeError: 'int' object is not iterable

I need your help

I am fitting data with minuit in ROOT in python enviroment (jupyter notebook)

My PDF is an exponential:

def pdf(x, *x0):
    return f

I define the Likelihodd function:

def LHM(*x0):
    n= invariant_mass.GetNbinsX()
    for i in n:
        frec= invariant_mass.GetBinContent()
        x = invariant_mass.GetBinCenter()
        f = f*(pdf(x,*x0))**(frec)
    return f       

The minuit fitting procedure:

minuit= ROOT.TVirtualFitter.Fitter(0,3)
arglist = np.empty(100)
minuit.ExecuteCommand("SET PRINT", arglist,1)

The problem begins here:


minuit.ExecuteCommand("MIGRAD", arglist, 2)

The problem is the third argument the int “2”. This is the error message:

TypeError                                 Traceback (most recent call last)
Cell In[411], line 8
      5 arglist[0]=500.0
      6 arglist[1]=0.01
----> 8 minuit.ExecuteCommand("MIGRAD", arglist, 2)

TypeError: int TFitter::ExecuteCommand(const char* command, double* args, int nargs) =>
    TypeError: 'int' object is not iterable

 **   60 **MINIMIZE         500        0.01

I have tried putting an int in C++ type, range(2), and other options, but none of them seem to work. I would appretiate your help.

Hi @Omar_Medina,

First of all, welcome to the ROOT forum! I guess @moneta can help with this.


1 Like

I think this is due to some issues in PyROOT to understand this interface. Since we do not recommend anymore to use the TFitter interface, but the ROOT::Math::Minimizer interface, you should use that one hen you just want to minimize a user provided function.
We have a Python example for it in the tutorial


1 Like

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