我正在使用python lmfit 模块来拟合多个Gaussian。我想要的是通过数学表达式将一个参数转换到另一个参数,例如:
$scope.formData = {
begin_date: new Date("2017-09-25")
};
我想要的是绑定参数,例如。 a1 = a2 / 2。有没有办法用lmfit包?
答案 0 :(得分:1)
是的,使用lmfit
,您可以使用数学表达式来控制任何参数的值。你可以这样做:
from lmfit.models import GaussianModel
# create model with two Gaussians
model = GaussianModel(prefix='g1_') + GaussianModel(prefix='g2_')
# create parameters for composite model, but with default values:
params = model.make_params()
# now set starting values, boundaries, constraints
params['g1_center'].set(5, min=1, max=7)
params['g2_center'].set(8, min=5, max=10)
# constrain sigma for 'g2' to be the same as for 'g1'
params['g2_sigma'].set(expr='g1_sigma')
# you could also do something like this:
params['g2_amplitude'].set(expr='g1_amplitude / 10.0')
# now you're ready to fit this model to some data:
result = model.fit(data, params, x=x)
答案 1 :(得分:0)
我刚刚在这里解决了我自己的非常相似的问题:
Scipy curve_fit bounds and conditions
我希望这有用,这些帮助了我: