0

I use curve_fit to fit a very simple line as below code:

from scipy.optimize import curve_fit

def func(x, a, b):
    return a * x + b

x = [6.6000000000000005, 7.599]
y = [123.9835274456227, 144.9319749893788]

popt, pcov = curve_fit(func,x,y,method='dogbox',p0=[20,-15])
print(popt) # get [ 20.96941696 -14.4146245 ]
print(pcov) # get [[inf inf], [inf inf]]

But the pcov result is inf. How can I get correct pcov values ?

ybdesire
  • 1,593
  • 1
  • 20
  • 35
  • Does this answer your question? [Why isn't \`curve\_fit\` able to estimate the covariance of the parameter if the parameter fits exactly?](https://stackoverflow.com/questions/41725377/why-isnt-curve-fit-able-to-estimate-the-covariance-of-the-parameter-if-the-pa) – joni Nov 24 '20 at 17:54
  • @joni, thanks for the comment. I do not think this is my case. Do you have any other suggestions? – ybdesire Nov 25 '20 at 08:22

1 Answers1

0

The result should be no value, since two points fit curve should no parameter error. So the covariance of parameters is zero.

ybdesire
  • 1,593
  • 1
  • 20
  • 35