请找到所附的图表。我需要找到点“a”和“b”。请建议python中的任何方法。
通过获取运行时间绘制图表,如下所示:
x = ([1000, 2000, 3000, 4000, 5000, 6000,7000, 8000, 9000])
和
y = ([2314,802,519,417,358,318,302,284,280])
需要找出“a”和“b”点,以便我可以将它们单独用于其他任务
完整代码:
def piecewise_linear(x, x0, y0, k1, k2):
return np.piecewise(x, [x < x0], [lambda x:k1*x + y0-k1*x0, lambda x:k2*x + y0-k2*x0])
perr_min = np.inf
p_best = None
for n in range(100):
k = np.random.rand(10)*20
p , e = optimize.curve_fit(piecewise_linear, x, y)
perr = np.sum(np.abs(y-piecewise_linear(x, *p)))
if(perr < perr_min):
print "success"
perr_min = perr
p_best = p
xd = np.linspace(min(x), max(x), 100)
plt.figure()
plt.plot(x, y, "bo")
y_out = piecewise_linear(xd, *p_best)
plt.plot(xd, y_out)
plt.ylabel('Number of KeyFrames')
plt.xlabel('Threshold Values')
plt.show()