Population strategies

Strategies to choose the population size.

The population size can be constant or can change over the course of the generations.

class pyabc.populationstrategy.AdaptivePopulationSize(start_nr_particles, mean_cv: float = 0.05, max_population_size: int = inf, min_population_size: int = 10, nr_samples_per_parameter: int = 1, n_bootstrap: int = 10, nr_calibration_particles: int = None)[source]

Bases: pyabc.populationstrategy.PopulationStrategy

Adapt the population size according to the mean coefficient of variation error criterion, as detailed in 1 . This strategy tries to respond to the shape of the current posterior approximation by selecting the population size such that the variation of the density estimates matches the target variation given via the mean_cv argument.

Parameters
  • start_nr_particles – Number of particles in the first populations

  • mean_cv – The error criterion. Defaults to 0.05. A smaller value leads generally to larger populations. The error criterion is the mean coefficient of variation of the estimated KDE.

  • max_population_size – Max nr of allowed particles in a population. Defaults to infinity.

  • min_population_size – Min number of particles allowed in a population. Defaults to 10

  • nr_samples_per_parameter – Defaults to 1.

  • n_bootstrap – Number of bootstrapped populations to use to estimate the CV. Defaults to 10.

  • nr_calibration_particles – Number of calibration particles.

1

Klinger, Emmanuel, and Jan Hasenauer. “A Scheme for Adaptive Selection of Population Sizes in ” Approximate Bayesian Computation - Sequential Monte Carlo.” Computational Methods in Systems Biology, 128-44. Lecture Notes in Computer Science. Springer, Cham, 2017. https://doi.org/10.1007/978-3-319-67471-1_8.

__call__(t: int = None) → int[source]

Call self as a function.

__init__(start_nr_particles, mean_cv: float = 0.05, max_population_size: int = inf, min_population_size: int = 10, nr_samples_per_parameter: int = 1, n_bootstrap: int = 10, nr_calibration_particles: int = None)[source]

Initialize self. See help(type(self)) for accurate signature.

get_config() → dict[source]

Get the configuration of this object.

Returns

Configuration of the class as dictionary

Return type

config

update(transitions: List[pyabc.transition.base.Transition], model_weights: numpy.ndarray, t: int = None)[source]

Select the population size for the next population.

Parameters
  • transitions – List of transitions.

  • model_weights – Array of model weights.

  • t – Time to adapt for.

class pyabc.populationstrategy.ConstantPopulationSize(nr_particles: int, nr_calibration_particles: int = None, nr_samples_per_parameter: int = 1)[source]

Bases: pyabc.populationstrategy.PopulationStrategy

Constant size of the different populations

Parameters
  • nr_particles – Number of particles per population.

  • nr_calibration_particles – Number of calibration particles.

  • nr_samples_per_parameter – Number of samples to draw for a proposed parameter.

__call__(t: int = None) → int[source]

Call self as a function.

__init__(nr_particles: int, nr_calibration_particles: int = None, nr_samples_per_parameter: int = 1)[source]

Initialize self. See help(type(self)) for accurate signature.

get_config() → dict[source]

Get the configuration of this object.

Returns

Configuration of the class as dictionary

Return type

config

class pyabc.populationstrategy.ListPopulationSize(values: Union[List[int], Dict[int, int]], nr_calibration_particles: int = None, nr_samples_per_parameter: int = 1)[source]

Bases: pyabc.populationstrategy.PopulationStrategy

Return population size values from a predefined list. For every time point enquired later (specified by time t), an entry must exist in the list.

Parameters
  • values (List[float]) – List of population size values. values[t] is the value for population t.

  • nr_calibration_particles – Number of calibration particles.

__call__(t: int = None) → int[source]

Call self as a function.

__init__(values: Union[List[int], Dict[int, int]], nr_calibration_particles: int = None, nr_samples_per_parameter: int = 1)[source]

Initialize self. See help(type(self)) for accurate signature.

get_config() → dict[source]

Get the configuration of this object.

Returns

Configuration of the class as dictionary

Return type

config

class pyabc.populationstrategy.PopulationStrategy(nr_calibration_particles: int = None, nr_samples_per_parameter: int = 1)[source]

Bases: abc.ABC

Strategy to select the sizes of the populations.

This is a non-functional abstract base implementation. Do not use this class directly. Subclasses must override the update method.

Parameters
  • nr_calibration_particles – Number of calibration particles.

  • nr_samples_per_parameter – Number of samples to draw for a proposed parameter. Default is 1.

abstract __call__(t: int = None) → int[source]

Call self as a function.

__init__(nr_calibration_particles: int = None, nr_samples_per_parameter: int = 1)[source]

Initialize self. See help(type(self)) for accurate signature.

get_config() → dict[source]

Get the configuration of this object.

Returns

Configuration of the class as dictionary

Return type

config

to_json() → str[source]

Return the configuration as json string. Per default, this converts the dictionary returned by get_config to json.

Returns

Configuration of the class as json string.

Return type

config

update(transitions: List[pyabc.transition.base.Transition], model_weights: numpy.ndarray, t: int = None)[source]

Select the population size for the next population.

Parameters
  • transitions – List of transitions.

  • model_weights – Array of model weights.

  • t – Time to adapt for.