是否有从最佳拟合散点图的直线中找到最远数据点的函数

问题描述 投票:0回答:1

[尝试从最佳拟合的直线找到最远的数据点,因此可以用作其他高斯拟合的初始猜测。需要最远的数据点,然后可以将其用作优化的粗略均值猜测。需要数据点的x值。

python curve-fitting scatter-plot
1个回答
0
投票

我将假设xval,yval和yfit都是数组。假设我在这里不丢失任何内容,则可以尝试如下操作:

import numpy as np

# create an array of delta values
delta_fit = abs(yvals - yfit)

# find the index where the maximum delta point is located
max_idx = np.argmax(delta_fit)

# get the xvals value at max_idx
max_xval = xvals[max_idx]

这假设您的数组具有相同的形状,并且您有兴趣确定与给定索引位置的拟合的最大距离。

© www.soinside.com 2019 - 2024. All rights reserved.