我试着解决这个问题有一段时间了,但我真的没有看到一个例子或任何我的大脑能够用来前进的东西。在
目标是通过最小化实际数据与需要合理估计的未知参数(高斯函数的位置、振幅和宽度未知)产生的模型之间的总卡平方最小来找到模型高斯曲线。scipy.optimize.fmin已经出现了,但是我以前从未使用过这个,而且我对python还是非常陌生的。。。在
最后,我想把原始数据和模型一起绘制出来——我以前用过pyplot,它只是生成模型并使用fmin,这让我完全搞不清自己到底在哪里:
def gaussian(a, b, c, x):
return a*np.exp(-(x-b)**2/(2*c**2))
我见过多种生成模型的方法,这让我很困惑,因此我没有代码!我已经通过导入了我的数据文件np.loadtxt文件. 在
感谢所有能提供框架或帮助的人。在
像这样的模型拟合问题基本上有四个(或五个)主要步骤:
下面是一个很好的例子,让您开始:
*有些解算器,例如共轭梯度法,将雅可比作为附加参数,这些解算器大体上更快、更健壮,但如果你感觉懒惰,性能也不是那么关键,那么你通常可以不用提供雅可比矩阵就可以逃脱,在这种情况下,它将使用有限差分法来估计梯度。在
您可以阅读有关不同解算器的更多信息here
相关问题 更多 >
编程相关推荐