I don't know the cause of Python TypeError. (scipy.optimize)

Asked 2 years ago, Updated 2 years ago, 105 views


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

2022-09-20 17:25

1 Answers

It was resolved by changing x from list to numpy array.

x = np.arange(0.1, 1.1, 0.1)


2022-09-20 17:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.