Open
Description
From @edbaskerville on December 9, 2014 23:33
It would be nice if Stan had some simple one-dimensional interpolation methods built in. (Not super-important, since this should be doable within a Stan model.)
One place this issue arises when implementing ODE models driven by empirical data sampled at discrete time intervals. Because the time derivative needs to be evaluated at arbitrary time points, the values of the driving variables need to be evaluated between sample times.
Even linear interpolation would be sufficient for many cases: e.g.,
data {
int nTimepoints;
real[nTimepoints] x;
}
// ...
x_t <- interpolate_linear(x, t);
would result in x_t
equal to a value linearly interpolated from x[i]
, x[i + 1]
, where i <= t <= i + 1
.
Copied from original issue: stan-dev/stan#1165