有没有一种方法可以使用 scipy.interpolate 在远离数据指定的边界条件下进行一维样条插值?
Is there a way to use scipy.interpolate to do 1d spline interpolation with boundary conditions specified away from data?
有很多方法可以直接从数据组装样条曲线,同时在边界处指定导数,但我没有看到从数据中指定导数约束 away 的简单方法。例如
np.random.seed(0)
M = 30
x = np.random.rand(M)
x.sort()
y = np.random.rand(M) + (10 * x) ** 2
xx = np.linspace(x.min(), x.max(), 100) # for plotting
import scipy.interpolate as si
f = si.make_interp_spline(x, y) # ok but how to add derivative conditions away from the x-values?
x_derivs = [-1, 2]
order_derivs = [2, 1]
value_derivs = [0, 1]
更一般地说,是否有内置方法来执行此操作或将导数约束与值约束分开?
我觉得只要创建算子矩阵就可以解决线性问题
简短回答:目前尚未实施。
你当然可以修改scipy源码,相关部分是
https://github.com/scipy/scipy/blob/v1.7.0/scipy/interpolate/_bsplines.py#L1105
有很多方法可以直接从数据组装样条曲线,同时在边界处指定导数,但我没有看到从数据中指定导数约束 away 的简单方法。例如
np.random.seed(0)
M = 30
x = np.random.rand(M)
x.sort()
y = np.random.rand(M) + (10 * x) ** 2
xx = np.linspace(x.min(), x.max(), 100) # for plotting
import scipy.interpolate as si
f = si.make_interp_spline(x, y) # ok but how to add derivative conditions away from the x-values?
x_derivs = [-1, 2]
order_derivs = [2, 1]
value_derivs = [0, 1]
更一般地说,是否有内置方法来执行此操作或将导数约束与值约束分开?
我觉得只要创建算子矩阵就可以解决线性问题
简短回答:目前尚未实施。
你当然可以修改scipy源码,相关部分是 https://github.com/scipy/scipy/blob/v1.7.0/scipy/interpolate/_bsplines.py#L1105