私は曲線があるとし、np.gradient
を使って有限差分を使って勾配を推定します。初期点x [0]と勾配ベクトルが与えられたら、元の曲線をどのように再構築できますか?数学的には、この方程式系を考えれば可能ですが、私はそれをプログラム的に行う方法は不明です。勾配から曲線を再構築する
ここに私のsin(x)があり、cos(x)と一致する数値の差を計算する簡単な例があります。
test = np.vectorize(np.sin)(x)
numerical_grad = np.gradient(test, 30./100)
analytical_grad = np.vectorize(np.cos)(x)
## Plot data.
ax.plot(test, label='data', marker='o')
ax.plot(numerical_grad, label='gradient')
ax.plot(analytical_grad, label='proof', alpha=0.5)
ax.legend();
カーブに特定の機能フォームが必要な場合を除き、3次スプライン(およびその他の滑らかなカーブ補間方法)を調べます。 – barrycarter