我正在尝试使用以下代码找到数据的最小二乘三次样条拟合:
from scipy import interpolate
plt.subplot(223)
l_hits = np.array(l_hits)
list1 = np.log(l_hits)
knots = list1.sort()
xnew = np.arange(min(l_bins), max(l_bins))
tck = interpolate.splrep(l_bins,list1,s=0,k=3,task=-1,t=knots)
fnew = interpolate.splev(xnew, tck, der=0)
plt.plot(xnew, fnew, 'b-')
其中 x 值为l_bins,y 值为np.log(l_hits) = list1。但我不断收到错误:
TypeError: Knots must be given for task =-1
为什么我会收到此错误,我该如何解决?