看来,你可能会点之间的插值之后,而不是拟合多项式参考文献:Spline Interpolation with Python和Fitting polynomials to data
然而,在这里无论是哪种情况是应该让你开始一个代码片段:
import numpy as np
import scipy as sp
from scipy.interpolate import interp1d
x = numpy.array([0,5,10,15,20,30,40,50])
y = numpy.array([0,0,0,12,40,40,40,40])
coeffs = numpy.polyfit(x, y, deg=4)#you can change degree as you see fit
poly = numpy.poly1d(coeffs)
yp = numpy.polyval(poly, x)
interpLength = 10
new_x = np.linspace(x.min(), x.max(), new_length)
new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x)
plt.plot(x, y, '.', x, yp, '-', new_x,new_y, '--')
plt.show()