/ Acedemic Notes

Scipy.optimize curve_fit problem

unsplash-logoChris Ried

Isn't able to estimate the covariance of the parameter, thus raising the OptimizeWarning below
Scipy Curve_fit

Today's lab ran into a problem that when people try to fit a function with
exponential and square root in it, the results is either off, or the
prameter does not work.

The problem is that if the fitting function tries to go through undefined points in your function, it throws out the warning above.

The importance of guessing is discussed in this thread, but the gist of it is, when fitting, use p0 argument to give initial point for fitting.

popt, pcov = curve_fit(func2, np.arange(10), np.arange(10), p0=(0, 0))
Akako L

Akako L

• Sophmore, HEP-ex Physics • Zelda, Splatoon • Casual Photography and OSU! • Decade-long DotA 2 player • Love Japanese Culture

Read More