bspline_interpolation#
- pymc_extras.utils.spline.bspline_interpolation(x, *, n=None, eval_points=None, degree=3, sparse=True)[source]#
使用 b 样条将稀疏网格插值到密集网格。
- 参数:
x (Variable) – 要插值的输入变量。第 0 个坐标假定规则地映射到 [0, 1] 区间
n (int (可选)) – 插值分辨率
eval_points (vector (可选)) – [0, 1] 区间中的自定义评估点(或使用最小/最大缩放适当缩放)
degree (int, 可选) – B 样条次数,默认为 3
sparse (bool, 可选) – 使用稀疏操作,默认为 True
- 返回:
插值后的变量,插值沿第 0 轴进行
- 返回类型:
Variable
示例
>>> import pymc as pm >>> import numpy as np >>> half_months = np.linspace(0, 365, 12*2) >>> with pm.Model(coords=dict(knots_time=half_months, time=np.arange(365))) as model: ... kernel = pm.gp.cov.ExpQuad(1, ls=365/12) ... # ready to define gp (a latent process over parameters) ... gp = pm.gp.gp.Latent( ... cov_func=kernel ... ) ... y_knots = gp.prior("y_knots", half_months[:, None], dims="knots_time") ... y = pm.Deterministic( ... "y", ... bspline_interpolation(y_knots, n=365, degree=3), ... dims="time" ... ) ... trace = pm.sample_prior_predictive(1)
注释
采用自 BayesAlpha,由 @aseyboldt 编写