Guest User

Untitled

a guest
May 10th, 2021
843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1.  
  2.     def y1(w,x,y,z):
  3.         return 3x\**4 + 0.5y\**3 + 2z\**2 + w
  4.     def y2(w,x,y,z):
  5.         return x*y * exp(z**2 - w)
  6.     def f(x0):
  7.         w,x,y,z = x0
  8.         error = []
  9.         #assuming your data is of the form
  10.         #expected_output = [(1,2),(3,4)]
  11.         for i in expected_output :
  12.             error += [ y1( w, x, y, z ) - i[0],
  13.                        y2( w, x, y, z ) - i[1],
  14.                      ]
  15.         return error
  16.     x0 = ( 0.1, 2, 0.03, 40 ) # initial parameters for w,x,y,z
  17.     result = scipy.optimize.leastsq( f, x0, epsfcn = 1e-3)
Advertisement
Add Comment
Please, Sign In to add comment