def func_y(x, a):
return (1 + a) * x / (a + x) #TypeError: can't multiply sequence by non-int of type 'float'
a = 0.0462
x = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
y = func_y(x, a)
popt, pcov = curve_fit(func_y, x, y)
What is the cause of the error? How can I solve this problem?
python typeerror
It was resolved by changing x from list to numpy array.
x = np.arange(0.1, 1.1, 0.1)
© 2024 OneMinuteCode. All rights reserved.