![]() |
Helpful Stan Functions
|
Functions | |
array[] vector | odeint_euler (real t0, vector y0, data real h, data int num_steps, array[] int a0, vector theta) |
array[] vector | odeint_midpoint (real t0, vector y0, data real h, data int num_steps, array[] int a0, vector theta) |
array[] vector | odeint_rk4 (real t0, vector y0, data real h, data int num_steps, array[] int a0, vector theta) |
These are explicit fixed-step ODE integrators, which evaluate the solution at an equispaced grid of time points. Interpolation can then be used to get the solution at other desired output time points. The functions assume that derivative_fun()
, which is the system function of the ODE, is defined earlier in the functions block. 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 built-in ODE solvers of Stan.
array[] vector odeint_euler | ( | real | t0, |
vector | y0, | ||
data real | h, | ||
data int | num_steps, | ||
array[]int | a0, | ||
vector | theta | ||
) |
Forward Euler method
Info: https://en.wikipedia.org/wiki/Euler_method
t0 | initial time |
y0 | initial state, D-vector |
h | step size (positive) |
num_steps | number of steps to take |
a0 | array of integer inputs given to derivative_fun() |
theta | parameter vector given to derivative_fun() |
num_steps + 1
array[] vector odeint_midpoint | ( | real | t0, |
vector | y0, | ||
data real | h, | ||
data int | num_steps, | ||
array[]int | a0, | ||
vector | theta | ||
) |
Explicit midpoint method
Info: https://en.wikipedia.org/wiki/Midpoint_method
t0 | initial time |
y0 | initial state, D-vector |
h | step size (positive) |
num_steps | number of steps to take |
a0 | array of integer inputs given to derivative_fun() |
theta | parameter vector given to derivative_fun() |
num_steps + 1
array[] vector odeint_rk4 | ( | real | t0, |
vector | y0, | ||
data real | h, | ||
data int | num_steps, | ||
array[]int | a0, | ||
vector | theta | ||
) |
Fourth-order Runge-Kutta method
Info: https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods
t0 | initial time |
y0 | initial state, D-vector |
h | step size (positive) |
num_steps | number of steps to take |
a0 | array of integer inputs given to derivative_fun() |
theta | parameter vector given to derivative_fun() |
num_steps + 1