我目前需要将 5PL 曲线拟合到我拥有的一些数据点。5PL 是一种非对称逻辑函数,常用于生物测定分析。其公式如下:
F(x) = D+(AD)/((1+(x/C)^B)^E)
我能够在 python (duh) 中使用 scipy 来获得拟合。我第一次使用我的数据知识来确定函数的起始参数:-
A is the lower asymptote so guess it with min(y)
B is the Hills slope so guess it with the slope of the line between first and last point.
C is the inflection point (the concentration of analyte where you have
half of the max response) so guess it finding the concentration whose
response is nearest to the mid response.
D is the upper asymptote so guess it with max(y)
E is the asymmetric factor and so guess it with no asymmetry (E=1) for starters.
然后我使用res = least_squares(residuals, p0,bounds=bnd args=(x, y))
where residuals 是计算我的数据和 5PL 函数之间的残差的函数,p0 包含我的初始参数,bnd 问题的边界和 args= 是传递给残差(我的数据)的参数。
现在结果是可以接受的,但我怀疑我的测量值有很强的异常值,我希望得到更可靠的结果。我发现您可以通过添加损失函数并修改 nonlin LS 来做到这一点(如此处所述。
解决这个问题的线变成res_loss = least_squares(residuals, p0, bounds=bnd,loss='soft_l1', f_scale=1000, args=(x, y))
了 loss='soft_l1' 确定我使用的损失函数的类型和 f_scale 内联值和异常值之间的阈值。
现在,在我能找到的每个示例中,人们只是使用他们想要拟合的曲线生成数据,并向该信号添加噪声。然后他们可以将 f_scale 值设置为等于他们引入的噪声。
这很好,但是如果不知道异常值的值是什么,应该如何选择 f_scale?有没有办法使用数据传播自动确定每个数据集的数据?
如果我的问题是线性的,我将只使用每个 X 处数据的 SD 来创建权重矩阵并求解加权最小二乘。非线性问题有类似的方法吗?
提前致谢