bspline_interpolation#
- pymc_extras.utils.spline.bspline_interpolation(x, *, n=None, eval_points=None, degree=3, sparse=True)[source]#
Interpolate sparse grid to dense grid using bsplines.
- Parameters:
x (Variable) – Input Variable to interpolate. 0th coordinate assumed to be mapped regularly on [0, 1] interval
n (int (optional)) – Resolution of interpolation
eval_points (vector (optional)) – Custom eval points in [0, 1] interval (or scaled properly using min/max scaling)
degree (int, optional) – BSpline degree, by default 3
sparse (bool, optional) – Use sparse operation, by default True
- Returns:
The interpolated variable, interpolation is across 0th axis
- Return type:
Variable
Examples
>>> 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)
Notes
Adopted from BayesAlpha where it was written by @aseyboldt