pyselfi.lotkavolterra.prior module

Routines related to the SELFI prior for time-dependent smooth functions.

class pyselfi.lotkavolterra.prior.lotkavolterra_prior(t_s, X0, Y0, theta_0, alpha_norm, t_smooth, t_chaos)[source]

Bases: object

This class represents the SELFI prior for time-dependent smooth functions.

The prior is a Gaussian with mean \(\boldsymbol{\theta}_0\) and covariance matrix \(\textbf{S} = \alpha_\mathrm{norm}^2 \textbf{V} \circ \textbf{K}\) (Hadamard product), such that: \(\textbf{K} = \begin{pmatrix} \textbf{K}_x & \textbf{0} \\ \textbf{0} & \textbf{K}_y \end{pmatrix}\), \((\textbf{K}_z)_{ij} = -\dfrac{1}{2} \left( \dfrac{t_i-t_j}{t_\mathrm{smooth}} \right)^2\), \(\textbf{V} = \begin{pmatrix} x_0 \textbf{u}\textbf{u}^\intercal & \textbf{0} \\ \textbf{0} & y_0 \textbf{u}\textbf{u}^\intercal \end{pmatrix}\), \((\textbf{u})_i = 1 + \dfrac{t_i}{t_\mathrm{chaos}}\).

Variables
  • t_s (array, double, dimension=S/2) – array of timesteps

  • theta_0 (array, double, dimension=S) – prior mean and blackbox expansion point

  • X0 (double) – initial condition (number of prey at t=0)

  • Y0 (double) – initial condition (number of predators at t=0)

  • alpha_norm (array, double, dimension=2) – overall amplitude of the prior covariance matrix (prey, predators)

  • t_smooth (array, double, dimension=2) – typical time parameter for the smoothness prior (prey, predators)

  • t_chaos (array, double, dimension=2) – typical time parameter for the time-dependent uncertainty (prey, predators)

_get_covariance()[source]

Gets the full prior covariance matrix as \(\textbf{S}\).

Returns

S – covariance matrix of the prior

Return type

array, double, dimension=(S,S)

_get_inverse_covariance()[source]

Gets the inverse covariance matrix.

Returns

inv_S – inverse covariance matrix of the prior

Return type

array, double, dimension=(S,S)

_get_rbf()[source]

Gets the radial basis function (RBF) part of the prior covariance matrix, \(\textbf{K}\).

Returns

K – RBF kernel

Return type

array, double, dimension=(S,S)

_get_time_variance()[source]

Gets the time-dependent part of the prior covariance matrix, \(\textbf{V} = \textbf{u}\textbf{u}^\intercal\).

Returns

V – time variance matrix

Return type

array, double, dimension=(S,S)

compute()[source]

Computes the prior (mean, covariance matrix and its inverse).

property gammaX

Defined by \(\gamma_X \equiv 1/(2 t_\mathrm{smooth}[0]^2)\).

Type

double

property gammaY

Defined by \(\gamma_Y \equiv 1/(2 t_\mathrm{smooth}[1]^2)\).

Type

double

get_alpha_norm()[source]

Gets alpha_norm (overall amplitude): \(\alpha_\mathrm{norm}[0]/x_0\).

get_t_chaos()[source]

Gets t_chaos (overall amplitude): \(t_\mathrm{chaos}[0]\).

get_t_smooth()[source]

Gets t_smooth (overall amplitude): \(t_\mathrm{smooth}[0]\).

classmethod load(fname)[source]

Loads the prior from an input file.

Parameters

fname (str) – input filename

Returns

prior – loaded prior object

Return type

prior

save(fname)[source]

Saves the prior to an output file.

Parameters

fname (str) – output filename

set_alpha_norm(alpha_norm)[source]

Sets alpha_norm as a 2-vector: \(\alpha_\mathrm{norm} [x_0,y_0]\).

set_t_chaos(t_chaos)[source]

Sets t_chaos as a 2-vector: \(t_\mathrm{chaos} [1,1]\).

set_t_smooth(t_smooth)[source]

Sets t_smooth as a 2-vector: \(t_\mathrm{smooth}[1,1]\).