2015-05-18 20 views

回答

1

你很可能谈到递归回归(这在Matlab中很容易)。对于python,请尝试使用scipy.optimize.curve_fit

对于简单的3度多项式拟合,这将基于numpy.polyfitpoly1d工作。

import numpy as np 
import matplotlib.pyplot as plt 

points = np.array([(1, 1), (2, 4), (3, 1), (9, 3)]) 
# get x and y vectors 
x = points[:,0] 
y = points[:,1] 

# calculate polynomial 
z = np.polyfit(x, y, 3) 
f = np.poly1d(z) 

# calculate new x's and y's 
x_new = np.linspace(x[0], x[-1], 50) 
y_new = f(x_new) 

plt.plot(x,y,'o', x_new, y_new) 
plt.xlim([x[0]-1, x[-1] + 1 ]) 
plt.show() 
+0

尽管我的数据集相当大,但让我试试这个。 –