我在使用RBF插值时遇到了一些错误。以下是一个一维的例子。我认为这与我的y值彼此之间的接近程度有关。有没有什么解决办法?
import numpy as np
from scipy.interpolate import Rbf, interp1d
import matplotlib.pyplot as plt
x = np.array([0.77639752, 0.8136646, 0.85093168, 0.88819876, 0.92546584, 0.96273292, 1.])
y = np.array([0.97119742, 0.98089758, 0.98937066, 0.99540737, 0.99917735, 1., 0.99779049])
xi = np.linspace(min(x),max(x),1000)
fig = plt.figure(1)
plt.plot(x,y,'ko', label='Raw Data')
#RBF
rbfi = Rbf(x,y, function='linear')
plt.plot(xi,rbfi(xi), label='RBF (linear)')
rbfi = Rbf(x,y, function='cubic')
plt.plot(xi,rbfi(xi), label='RBF (cubic)')
#1D
f = interp1d(x,y, kind='cubic')
plt.plot(xi,f(xi), label='Interp1D (cubic)')
plt.plot(x,y,'ko', label=None)
plt.grid()
plt.legend()
plt.xlabel('x')
plt.ylabel('y')
plt.tight_layout()
plt.savefig('RBFTest.png')