在 lmfit() 中使用 x 和 y 不确定性

Using x and y uncertainties in lmfit()

提问人:Phasco 提问时间:11/13/2023 更新时间:11/13/2023 访问量:12

问:

我想在 python 中使用 lmfit 将一个简单的线性模型拟合到我的数据中。我的数据在 y 分量和 x 分量上也存在不确定性。据我所知,获取 y 组件的权重,如下面的代码中使用 1/yerr。但是,我怎样才能同时考虑xerr呢?lmfit()

代码说明: (我懒得每次都写unp.nominal_values所以我定义了简称函数) 数组 B_field 和 energy_plus 具有 ufloats 作为元素。 我使用内置函数定义线性模型,给出我猜测的参数,并通过给出 y 分量、初始猜测、x 分量和 yarr 的权重进行拟合。

def unp_nv(x):
    return unp.nominal_values(x)
def unp_sd(x):
    return unp.std_devs(x)

bohr_plus_model = LinearModel(prefix="lin_")
bohr_plus_params = bohr_plus_model.make_params(m=-0.00005, b=-0.5)
bohr_plus_result = bohr_plus_model.fit(unp_nv(energy_plus),params=bohr_plus_params,x=unp_nv(B_field),weights=1/unp_sd(energy_plus))

就我在这里的文档中读到的,没有这种可能性。

蟒蛇 LMFIT的

评论


答: 暂无答案