我试图用python找到曲线上的拐点。曲线的数据如下:https://www.dropbox.com/s/rig8frgewde8i5n/fitted.txt?dl=0。请注意,曲线已与原始数据拟合。此处提供原始数据:https://www.dropbox.com/s/1lskykdi1ia1lu7/ww.txt?dl=0
import numpy as np
# Read in array from text file
arr = np.loadtxt(path_to_file)
inflexion_point_1 = np.diff(arr).argmin()
inflexion_point_2 = np.diff(arr).argmax()
这两个拐点在附图中显示为红线。然而,他们的位置似乎并不正确。第一个拐点应靠近黑色箭头指示的区域。我怎么解决这个问题?在
另外,下面是微分曲线图:
^{pr2}$正如您所看到的,代码的行为是编码的,即它找到的argmaxnp差异数组的。不过,我想找一个离第110天更近的位置,也就是说,离argmax大约一半。在
--编辑--
另外,这是另一个显示原始数据和拟合曲线的曲线图(使用二次函数)。在
有什么理由不直接在梯度上使用单变量样条函数?在
我们也可以用数值求解最大值:
^{pr2}$相关问题 更多 >
编程相关推荐