birdepy.simulate.discrete()

birdepy.simulate.discrete(param, model, z0, times, k=1, method='exact', tau=0.1, survival=False, seed=None, display=False, **options)

Simulation of continuous-time birth-and-death processes at discrete observation times.

Parameters:
  • param (array_like) – The parameters governing the evolution of the birth-and-death process to be simulated. Array of real elements of size (m,), where ‘m’ is the number of parameters. These must be in the order given here).

  • model (string) –

    Model specifying birth and death rates of process (see here). Should be one of:

    • ’Verhulst’

    • ’Ricker’

    • ’Hassell’

    • ’MS-S’

    • ’pure-birth’

    • ’pure-death’

    • ’Poisson’

    • ’linear’

    • ’linear-migration’

    • ’M/M/1’

    • ’M/M/inf’

    • ’loss-system’

    • ’custom’

    If set to ‘custom’, then kwargs b_rate and d_rate must also be specified. See here for more information.

  • z0 (int or callable) –

    The initial population size for each sample path. If it is a callable it should be a function that has no arguments and returns an int:

    z0() -> int

  • times (array_like) – The times at which the simulated birth-and-death is observed. Array of real elements of size (n,), where ‘n’ is the number of observation times.

  • k (int, optional) – The number of sample paths to be simulated.

  • method (string, optional) –

    Simulation algorithm used to generate samples (see here). Should be one of:

    • ’exact’ (default)

    • ’ea’

    • ’ma’

    • ’gwa’

  • tau (scalar, optional) – Time between samples for the approximation methods ‘ea’, ‘ma’ and ‘gwa’.

  • survival (bool, optional) – If set to True, then the simulated sample paths are conditioned to have a positive population size at the final observation time. Since This can greatly increase computation time.

  • seed (int, Generator, optional) – If seed is not specified the random numbers are generated according to np.random.default_rng(). If seed is an int, random numbers are generated according to np.random.default_rng(seed). If seed is a Generator, then that object is used. See here for more information.

  • display (bool, optional) – If set to True, then a progress indicator is printed as the simulation is performed.

Returns:

out – If k=1 a list containing sampled population size observations at times, generated according to model. Or if k>1, a numpy.ndarray containing k sample paths, each contained in a row of the array.

Return type:

array_like

Examples

Simulating a unit rate Poisson process with observations at times [0, 1, 2, 3, 4, 5]:

import birdepy as bd
bd.simulate.discrete(1, 'Poisson', 0, times=[0, 1, 3, 4, 5])
[0, 1, 3, 5, 5]

Notes

If you use this function for published work, then please cite [1].

Sample paths are generated using a discrete-event simulation algorithm. See, for example, Algorithm 5.8 in [2].

For a text book treatment on the theory of birth-and-death processes see [3].

References

[View birdepy.simulate.discrete() source code]