Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't `curve_fit` able to estimate the covariance of the parameter if the parameter fits exactly?

Tags:

I don't understand curve_fit isn't able to estimate the covariance of the parameter, thus raising the OptimizeWarning below. The following MCVE explains my problem:

MCVE python snippet

from scipy.optimize import curve_fit func = lambda x, a: a * x popt, pcov = curve_fit(f = func, xdata = [1], ydata = [1]) print(popt, pcov) 

Output

\python-3.4.4\lib\site-packages\scipy\optimize\minpack.py:715: OptimizeWarning: Covariance of the parameters could not be estimated category=OptimizeWarning)  [ 1.] [[ inf]] 

For a = 1 the function fits xdata and ydata exactly. Why isn't the error/variance 0, or something close to 0, but inf instead?

There is this quote from the curve_fit SciPy Reference Guide:

If the Jacobian matrix at the solution doesn’t have a full rank, then ‘lm’ method returns a matrix filled with np.inf, on the other hand ‘trf’ and ‘dogbox’ methods use Moore-Penrose pseudoinverse to compute the covariance matrix.

So, what's the underlying problem? Why doesn't the Jacobian matrix at the solution have a full rank?