pyselfi_examples.lotkavolterra.model.blackbox_LV module

A blackbox to simulate prey and predator populations and observations from the Lotka-Volterra model. See section III in Leclercq (2022) for a description of the Lotka-Volterra data model.

class pyselfi_examples.lotkavolterra.model.blackbox_LV.blackbox(P, X0, Y0, seed, fixnoise, **metaparams)[source]

Bases: object

This class represents a SELFI blackbox.

Variables
  • P (int) – number of output summary statistics. This is the only mandatory argument

  • X0 (double) – initial condition: number of prey

  • Y0 (double) – initial condition: number of predators

  • seed (int) – (first) random seed to be used for the realizations

  • fixnoise (bool) – fix the noise realization? if True the seed used will always be seed

  • model (int, optional, default=0) – 0= correct data model; 1=misspecified data model

  • threshold (double) – maximum number of individuals (prey or predators) that can be observed

  • mask (array, double, dimension=n) – a mask containing zeros and ones

  • Xefficiency (array, double, dimension=len(t)) – detection efficiency of prey as a function of time

  • Yefficiency (array, double, dimension=len(t)) – detection efficiency of prey as a function of time

  • obsP (double) – rate of prey misses due to correlation between prey and predators

  • obsQ (double) – rate of predator misses due to correlation between prey and predators

  • obsR (double) – strength of demographic noise

  • obsS (double) – overall strength of observational noise

  • obsT (double) – strength of non-diagonal term in observational noise

Xobs(S, mask)[source]

Evalutes the timesteps at which prey observations are defined.

Parameters
  • S (int) – number of input parameters

  • mask (array, double, dimension=S) – a mask containing zeros and ones

Returns

Xobs – array containing timesteps, such that PX=np.sum(mask)

Return type

array, double, dimension=PX

Yobs(S)[source]

Evalutes the timesteps at which predator observations are defined.

Parameters

S (int) – number of input parameters

Returns

Yobs – array containing timesteps (np.arange(S//2))

Return type

array, double, dimension=S/2

compute_pool(theta, d, pool_fname, N)[source]

Computes a pool of realizations of the blackbox.

Parameters
  • theta (array, double, dimension=S) – vector of input parameters

  • d (int) – direction in parameter space, from 0 to S

  • pool_fname (str) – pool file name

  • N (int) – number of realizations required

Returns

p – simulation pool

Return type

pool

evaluate(theta, seed=None, i=0, N=0)[source]

Evaluates the blackbox from an input vector of parameters.

Parameters
  • theta (array, double, dimension=S) – vector of input parameters

  • seed (int, optional, default=None) – value of the seed to generate the realization, uses current state if set to None

  • i (int, optional, default=0) – current evaluation index of the blackbox

  • N (int, optional, default=0) – total number of evaluations of the blackbox

Returns

Phi – vector of summary statistics

Return type

array, double, dimension=P

make_data(theta_true, seed=None)[source]

Evaluates the blackbox to make mock data.

Parameters
  • theta_true (array, double, dimension=S) – vector of true input parameters

  • seed (int, optional, default=None) – value of the seed to generate the realization, uses current state if set to None

Returns

Phi – vector of summary statistics

Return type

array, double, dimension=P

make_demographic_noise_cov(theta_true)[source]

Evaluates the demographic noise covariance matrix.

Parameters

theta_true (array, double, dimension=S) – vector of true input function

Returns

D – demographic noise covariance matrix

Return type

array, double, dimension=(S,S)

make_observational_noise_cov(theta_true)[source]

Evaluates the observational noise covariance matrix.

Parameters

theta_true (array, double, dimension=S) – vector of true input function

Returns

O – observational noise covariance matrix

Return type

array, double, dimension=(S,S)

make_signal(theta_true)[source]

Evaluates the blackbox to make mock unobserved signal.

Parameters

theta_true (array, double, dimension=S) – vector of true input function

Returns

theta_signal – vector of unobserved signal

Return type

array, double, dimension=S