![]() |
Helpful Stan Functions
|
Functions | |
array[] vector | interp_1d_cubic (array[] vector y, data array[] real x, data array[] real x_out, array[] int a0, vector theta) |
array[] vector | interp_1d_linear (array[] vector y, data array[] real x, data array[] real x_out) |
These functions perform interpolation one dimension at a time.
array[] vector interp_1d_cubic | ( | array[]vector | y, |
data array[]real | x, | ||
data array[]real | x_out, | ||
array[]int | a0, | ||
vector | theta | ||
) |
1d interpolation using cubic Hermite splines
The interpolated value \(y = g(x)\) is given by a cubic polynomial \(g\), defined uniquely by four values \(y_0 = g(x_0)\), \(y_1 = g(x_1)\), \(f_0 = g'(x_0)\), and \(f_1 = g'(x_1)\), where \(x_0 < x \leq x_1\). Assumes that derivative_fun()
, which evaluates \(g'(x)\), is defined in th functions block before this function. It must have signature
vector derivative_fun(real t, vector y, int[] a0, vector a1)
i.e. same as what can be used with the Stan ODE solvers but it shouldn't actually use the t argument. It will be always called with t = 0.0
.
Info: https://en.wikipedia.org/wiki/Cubic_Hermite_spline
y | array of D-vectors, length N_in |
x | incresing array of reals, length N_in |
x_out | increasing array of reals, length N_out , values must be in \((\min(x), \max(x)]\) |
a0 | array of integer inputs given to derivative_fun() |
theta | parameter vector given to derivative_fun() |
N_out
, corresponding to interpolated values y_out
array[] vector interp_1d_linear | ( | array[]vector | y, |
data array[]real | x, | ||
data array[]real | x_out | ||
) |
Linear 1d interpolation
y | array of D-vectors, length N_in |
x | incresing array of reals, length N_in |
x_out | increasing array of reals, length N_out , values must be in \((\min(x), \max(x)]\) |
N_out
, corresponding to interpolated values y_out