私は次のコードを使用して、いくつかのデータに合うようにしようとしています動作しません:私はないです何のscipyのダウンロードcurve_fitはよく
任意の考え:このプロットを作る
import numpy as np
import scipy.optimize
import matplotlib.pyplot as plt
def fseries(x, a0, a1, b1, w):
f = a0 + (a1 * np.cos(w * x)) + (b1 * np.sin(w * x))
return f
x = np.arange(0, 10)
y = [-45.0, -17.0, -33.0, 50.0, 48.0, -3.0, -1.0, 2.0, 84.0, 71.0]
res = scipy.optimize.curve_fit(fseries, x, y, maxfev=10000)
xt = np.linspace(0, 10, 100)
yt = fseries(xt, res[0][0], res[0][1], res[0][2], res[0][3])
plt.plot(x,y)
plt.plot(xt, yt, 'r')
plt.show()
理解や間違っている?
それぞれのシリーズのサンプル数がn = 100と比較してn = 10であるため、n = 100のときに空白が多く残っています。 – DrBwts