使用不等式星形混合建模约束参数

问题描述

我正在尝试混合两个高斯,但我不知道如何使一个高斯的参数大于另一个高斯的参数。

# Generate fake data
np.random.seed(42)
g1 = models.Gaussian1D(0.7,-0.5,0.2)
g2 = models.Gaussian1D(0.3,0.5,0.1)
x = np.linspace(-1,1,200)
y = g1(x) + g2(x) + np.random.normal(0.,0.1,x.shape)

# Now to fit the data create a new superposition with initial
# guesses for the parameters:
gg_init = models.Gaussian1D(1,0.0,0.2) + models.Gaussian1D(0,0.1)
fitter = fitting.SLSQPLSQFitter()
gg_fit = fitter(gg_init,x,y)

# Plot the data with the best-fit model
plt.figure(figsize=(8,5))
plt.plot(x,y,'ko')
plt.plot(x,gg_fit(x))
plt.xlabel('Position')
plt.ylabel('Flux')

上面的代码与 astropy 文档中的示例几乎相同:https://docs.astropy.org/en/stable/modeling/compound-models.html。假数据由均值为 -0.5 的 g1 加上均值为 0.5 的 g2 组成。我最初的猜测是两个均值为 0.0 的高斯分布。如何将 g1 和 g2 的拟合均值联系起来,使得 g1 的均值大于 g2 的均值。在这个例子中,我希望 g1 的平均值为 -0.5,g2 的平均值为 0.5。

我找不到任何可帮助解决此问题的文档。

感谢任何帮助:)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)