optimization - How to minimize my nasty function using scipy.minimize? -
i trying minimize function using scipy.minimize. columns of text file imported integers. codes work except last 2 lines.
from sympy.abc import * import sympy s import numpy n scipy.optimize import minimize h0,mo,e,z,g = s.symbols('h0 mo e z g') dz = ((1+z)/h0)*(s.integrate(s.nsimplify((6/h0)/(g+(6-g)*(1+z)**3),z),z)).doit() mt = 5*s.log(10**(5)*dz)+25 c1 = ((mt-mo)**2)/e**2 c2 = s.lambdify((h0,g,z,mo,e),c1,"numpy") c3 = n.vectorize(c2) data = n.genfromtxt('data_file_580.txt',usecols=[1,2,3]) z = data[:,[0]] mo = data[:,[1]] e = data[:,[2]] c4 = c3(z,mo,e,g,h0) c5 = n.sum(c4) def f(c5): h0,g=c5 return c5 bnds = ((65,80),(4,6)) minimize(f,(65,4),bounds=bnds)
getting error
valueerror: setting array element sequence.
if use def f(h0,g)
instead of def f(c5)
in line 17, throwing error
typeerror: f() missing 1 required positional argument: 'g'
how resolve ?
Comments
Post a Comment