【发布时间】:2019-09-10 17:04:54
【问题描述】:
我正在尝试将一个非常复杂的(扁平高斯)模型拟合到我获得的数据中。 Image for flattened Gaussian formula (这里我的代码中的变量 fc 代表 vo,中心频率。)
我已经使用 from scipy.optimize import curve_fit 在 python 中编写了代码。 它无法优化我的方程,并且总是对参数给出相同的答案。 数据文件链接:https://www.filehosting.org/file/details/795968/my-file.dat
import numpy as np
from scipy.optimize import curve_fit
x = np.loadtxt("my-file.dat")[:,0]
yres = np.loadtxt("my-file.dat")[:,1]
def flatgauss(x, A,fc,t,w):
B= ((4*(x-fc)**2)/ w**2 ) * np.log((-1/t)*np.log((1+ np.exp(-t))/2))
return -A*( (1-np.exp(-t*np.exp(B)))/ (1-np.exp(-t)) )
popt, pcov = curve_fit(flatgauss, x, yres)
print ("fitted parameters:", popt)
这是我得到的: OptimizeWarning:无法估计参数的协方差 类别=优化警告) 拟合参数:[1. 1. 1. 1.]
请帮助我使用 scipy 或您认为好的任何其他模块来安装它。 (像司仪)
【问题讨论】:
-
能否发个数据文件的链接?
-
是的,我现在已经编辑了帖子以包含指向数据文件的链接。这里是:filehosting.org/file/details/795968/my-file.dat>
-
我不想接受他们的服务条款或给他们我的电子邮件地址,这两个都是下载链接所必需的。
-
尝试通过 zunzun@zunzun.com 给我发送电子邮件
-
好的,这里是另一个链接,您不需要接受任何条款或需要提供电子邮件 ID。 mediafire.com/file/7puj3hanac8aklr/my-file.dat/file>
标签: python optimization scipy curve-fitting