我正在尝试使用三次样条插值,但插值在数据点周围波动很大。 我不知道如何解决这个问题。任何建议都将不胜感激。
TY = [90.3601709789,40.5189212844,20.3763456417,10.8899070251,6.19675122846,5.23402053792,6.05144428822,9.64276229024,24.1886072903,41.5725945652,171.923304843]
TX = [0.93984962406,0.90225563910,0.84586466165,0.75187969925,0.56390977444,0.37593984962,0.18796992481,0.07518796992,0.01879699248,0.00939849624,0.00187969925]
ipos = TX[0:6]
jpos = TY[0:6]
minpos = min(jpos)
maxpos = max(jpos)
ineg = TX[5:11]
jneg = TY[5:11]
minneg = min(jneg)
maxneg = max(jneg)
ypos1 = interp1d(jpos,ipos)
ypos2 = interp1d(jpos,ipos, kind='cubic')
xpos = np.linspace(minpos,maxpos,10000,endpoint=True)
yneg1 = interp1d(jneg,ineg)
yneg2 = interp1d(jneg,ineg, kind='cubic')
xneg = np.linspace(minneg,maxneg,10000,endpoint=True)
plt.figure('T')
plt.xscale('log')
plt.plot(TX,TY)
plt.plot(xpos,ypos2(xpos))
plt.plot(xneg,yneg2(xneg))
正面和负面部分是因为数据在中点改变方向。
答案 0 :(得分:0)
已知立方样条由于需要连续的二阶导数而易于振荡。为了避免这种情况,一种方法是使用C1连续样条。在scipy土地上,看看PchpIntetpolator和/或Akima1DInterpolator