Hi
i am trying to minimize a function using the following code. i use pyminuit which calls minuit program. You may not familiar with this module, but I hope u could help me.
import minuit
data = [(1,1.1,0.1), (2,1.9,0.1), (3,2.9,0.1), (4,4.1,0.1)]
def f(x, a, b): return a + b*x
def chi2(a, b):
c2 = 0.
for x, y, yerr in data:
c2 += (f(x, a, b) - y)**2 / yerr**2
return c2
m = minuit.Minuit(chi2, **p)
m.migrad()
print m.values
Here I have defined my parameters initial values as dictionary. I would like to minimize this with respect to 'a' and 'b'. The above one is working program.
m = minuit.Minuit(chi2, **p) will take the valuse from dictionary as initial condition. But if I change chi2(a,b) to chi(**p) then it says an error "TypeError: This function has no parameters to minimize.". I need to pass some arbitrary number of parameters in my program. so how to tell the function chi2 what are the parameters using dictionary?
Thanks
Vinu V