Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def y1(w,x,y,z):
- return 3x\**4 + 0.5y\**3 + 2z\**2 + w
- def y2(w,x,y,z):
- return x*y * exp(z**2 - w)
- def f(x0):
- w,x,y,z = x0
- error = []
- #assuming your data is of the form
- #expected_output = [(1,2),(3,4)]
- for i in expected_output :
- error += [ y1( w, x, y, z ) - i[0],
- y2( w, x, y, z ) - i[1],
- ]
- return error
- x0 = ( 0.1, 2, 0.03, 40 ) # initial parameters for w,x,y,z
- result = scipy.optimize.leastsq( f, x0, epsfcn = 1e-3)
Advertisement
Add Comment
Please, Sign In to add comment