Type Alias Drift
pub type Drift = fn(_: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, _: &Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, _: f64, _: &mut Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, _: Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>, _: &Covariates);
Expand description
This closure represents the drift term of a stochastic differential equation model.
§Parameters
x
: The state vector at time tp
: The parameters of the model; Use the [fetch_params!] macro to extract the parameterst
: The time at which the drift term is evaluateddx
: A mutable reference to the derivative of the state vector at time trateiv
: A vector of infusion rates at time tcov
: A reference to the covariates at time t; Use the [fetch_cov!] macro to extract the covariates
§Example
ⓘ
use pharmsol::*;
let drift = |x, p, t, dx, rateiv, cov| {
fetch_params!(p, mka, mke, v);
fetch_cov!(cov, t, wt);
ka = dx[2];
ke = dx[3];
dx[0] = -ka * x[0];
dx[1] = ka * x[0] - ke * x[1];
dx[2] = -dx[2] + mka; // Mean reverting to mka
dx[3] = -dx[3] + mke; // Mean reverting to mke
};