Numpy 5PL曲线非线性最小二乘法(scipy)中的异常值处理

Numpy 5PL曲线非线性最小二乘法(scipy)中的异常值处理,numpy,scipy,least-squares,non-linear-regression,loss-function,Numpy,Scipy,Least Squares,Non Linear Regression,Loss Function,我目前需要将5PL曲线拟合到我拥有的一些数据点。5PL是生物测定分析中常用的非对称逻辑函数。其公式如下: F(x)=D+(A-D)/(1+(x/C)^B^E) 我使用python中的scipy(duh)获得了一个合适的结果。 我第一次使用数据知识来确定函数的起始参数:- 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 betwe

我目前需要将5PL曲线拟合到我拥有的一些数据点。5PL是生物测定分析中常用的非对称逻辑函数。其公式如下:

F(x)=D+(A-D)/(1+(x/C)^B^E)

我使用python中的scipy(duh)获得了一个合适的结果。 我第一次使用数据知识来确定函数的起始参数:-

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))其中residuals是计算我的数据和5PL函数之间的残差的函数,p0包含我的初始参数,bnd问题的边界,args=是传递给residuals(我的数据)的参数

现在,结果是可以接受的,但我怀疑我的测量值有很强的异常值,我希望得到更可靠的结果。我发现您可以通过添加一个损失函数和修改nonlin LS来实现这一点(如前所述)

解决这个问题的方法是
res_loss=least_squares(残差,p0,界限=bnd,loss='soft_l1',f_scale=1000,args=(x,y))
其中loss='soft_l1'确定我使用的损失函数的类型,f_在内联线和异常值之间缩放阈值

现在在我能找到的每一个例子中,人们只是使用他们想要拟合的曲线来生成数据,并向信号中添加噪声,然后他们可以将f_scale值设置为等于他们引入的噪声

这很好,但如果不知道异常值的值是什么,那么应该如何选择f_scale?是否有一种方法可以使用数据分布自动确定每个数据集的异常值

如果我的问题是线性的,我会用每个X的数据的标准差来创建一个权重矩阵并求解加权最小二乘法。对于非线性问题有类似的方法吗


提前感谢

这似乎是一个统计问题,而不是一个编程问题,在这种情况下,最好把它放进去,比如。