Python scipy: unsupported operand type(s) for ** or pow(): list and list
Python scipy: unsupported operand type(s) for ** or pow(): list and list
It looks like youre after element-wise power-raising?
Like a*x[i]**(b*x[i])
for each i?
In that case, you have to use the np.power
function:
def func(x,a,b):
return a*np.power(x,b*x)
Then it works.
(As an aside, it may be worthwhile to convert x
and y
from lists to numpy arrays: np.array(x)
).