pfjax.models.lotvol_model
Module Contents
Classes
Lotka-Volterra predator-prey model. |
- class pfjax.models.lotvol_model.LotVolModel(dt, n_res)[source]
Bases:
pfjax.sde.SDEModelLotka-Volterra predator-prey model.
The model is:
exp(x_m0) = exp( (logH_m0, logL_m0) ) ~ pi(x_m0) \propto 1 logH_mt ~ N(logH_{m,t-1} + (alpha - beta exp(logL_{m,t-1})) dt/m, sigma_H^2 dt/m) logL_mt ~ N(logL_{m,t-1} + (-gamma + delta exp(logH_{m,t-1})) dt/m, sigma_L^2 dt/m) y_t ~ N( exp(x_{m,mt}), diag(tau_H^2, tau_L^2) )
Model parameters: theta = (alpha, beta, gamma, delta, sigma_H, sigma_L, tau_H, tau_L).
Global constants: dt and n_res, i.e., m.
State dimensions: n_state = (n_res, 2).
Measurement dimensions: n_meas = 2.
Notes:
The measurement y_t corresponds to x_t = (x_{m,(t-1)m+1}, …, x_{m,tm}), i.e., aligns with the last element of x_t.
The prior is such that p(x_0 | y_0, theta) is given by:
x_{m,n} = 0 for n = -m+1, ..., -1, exp(x_{m0}) ~ TruncatedNormal( y_0, diag(tau_H^2, tau_L^2) ),
where
z ~ TruncatedNormal(mu, diag(sigma^2)) <=> z = mu + diag(sigma) Z_0, Z_0 ~iid N(0,1) truncated at -mu.
- Parameters
dt – SDE interobservation time.
n_res – SDE resolution number. There are n_res latent variables per observation, equally spaced with interobservation time dt/n_res.
- meas_lpdf(y_curr, x_curr, theta)[source]
Log-density of p(y_curr | x_curr, theta).
- Parameters
y_curr – Measurement variable at current time t.
x_curr – State variable at current time t.
theta – Parameter value.
- Returns
The log-density of p(y_curr | x_curr, theta).
- meas_sample(key, x_curr, theta)[source]
Sample from p(y_curr | x_curr, theta).
- Parameters
key – PRNG key.
x_curr – State variable at current time t.
theta – Parameter value.
- Returns
y_curr ~ p(y_curr | x_curr, theta).
- Return type
Sample of the measurement variable at current time t
- pf_init(key, y_init, theta)[source]
Importance sampler for x_init.
See file comments for exact sampling distribution of p(x_init | y_init, theta), i.e., we have a “perfect” importance sampler with logw = CONST(theta).
- Parameters
key – PRNG key.
y_init – Measurement variable at initial time t = 0.
theta – Parameter value.
- Returns
x_init: A sample from the proposal distribution for x_init.
logw: The log-weight of x_init.
- Return type
Tuple