更新时间:2023-02-26 15:41:17
插值函数scipy.interpolate.interp1d
还可用于插值的矢量值数据(尽管不适用于矢量值参数数据).因此,只要x
是标量,就可以直接使用它.
The interpolation function scipy.interpolate.interp1d
also works on vector-valued data for the interpolant (not for vector-valued argument data though). Thus, as long as x
is scalar, you can use it directly.
以下代码是 scipy文档:
>>> from scipy.interpolate import interp1d
>>> x = np.linspace(0, 10, 10)
>>> y = np.array([np.exp(-x/3.0), 2*x])
>>> f = interp1d(x, y)
>>> f(2)
array([ 0.51950421, 4. ])
>>> np.array([np.exp(-2/3.0), 2*2])
array([ 0.51341712, 4. ])
请注意,参数向量x
中没有2,因此在此示例中,y
中第一个分量的插值误差.
Note that 2 is not in the argument vector x
, thus the interpolation error for the first component in y
in this example.