[英]Python: how can I get the smoother-starting-point in graph?
您正在尋找的是更准確的斜率或一階差分,為了了解曲線開始平滑的位置,您可以計算一階差分/斜率並找出斜率低於某個閾值的第一個指數:
import matplotlib.pyplot as plt
import numpy as np
x = np.array(range(10))
y = np.array([0.3, 0.37, 0.41, 0.52, 0.64, 0.68, 0.71, 0.72, 0.73, 0.74])
slopes = np.diff(y) / np.diff(x)
idx = np.argmax(slopes < 0.02) # find out the first index where slope is below a threshold
fig, ax = plt.subplots()
ax.plot(x, y)
ax.scatter(x[idx], y[idx], s=200, facecolors='none', edgecolors='r')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.