科学估计的协方差不好

时间:2019-10-13 07:55:09

标签: scipy-optimize

我必须在我的数据集中拟合一个指数方程。 但它给出了一个错误::minpack.py:787:OptimizeWarning:

无法估计参数的协方差

为什么会出现此错误?没有估计协方差系数。请解决。代码如下:     在此处输入代码     将numpy导入为np     将熊猫作为pd导入     导入matplotlib.pyplot作为plt     将scipy导入为sp     将seaborn导入为sns     从scipy进口统计     从scipy导入优化     从scipy.optimize.minpack导入curve_fit

inti= pd.read_excel('CNIC_N_INDIAN_PLATE_CARI.xls')
x= np.array(inti.year)
y= np.array(inti.RES)
# define fitting function
def func(x, b, c):
return -b *(1- np.exp(-x/c))

popt, pcov = curve_fit(func, x,y)
plt.figure()
plt.plot(year, res, 'ko', label="Data")
plt.plot(year, func(year, *popt), 'r-', label="Fitted Curve")
plt.legend()
plot(x, yy)
plt.showprint("popt coefficient:") 
print(popt) 
print("Covariance of coefficients:") 
print(pcov)

0 个答案:

没有答案