我试图使用scipy curve_fit将一个简单的指数拟合到一些数据中,结果是指数,其数量级太大了。import matplotlib.pyplot as pltfrom scipy.optimize import curve_fitimport mathimport numpy as npcases_DE = [16,18,26,48,74,79,130,165,203,262,545,670,800,1040,1224,1565,1966,2745,3675,4599,5813, 7272, 9367, 12327]def simple_DE(A,c,t): return A*math.e**(c*t)range_thing = np.array(range(len(cases_DE)))popt, pcov = curve_fit(simple_DE, range_thing, cases_DE, bounds=((-np.inf, 0), (np.inf, 1)))print(popt)plt.scatter(range_thing, simple_DE(*popt, range_thing))plt.scatter(range_thing, cases_DE)print(simple_DE(*popt, 20))plt.xlabel('x')plt.ylabel('y')plt.show()任何人都可以告诉我我哪里错了吗?
添加回答
举报
0/150
提交
取消