Population stratgy¶
Strategies to choose the population size.
The population size can be constant or can change over the course of the generations.

class
pyabc.populationstrategy.
PopulationStrategy
(nr_particles: int, *, nr_samples_per_parameter: int = 1)¶ Strategy to select the sizes of the populations.
This is a nonfunctional abstract base implementation. Do not use this class directly. Subclasses must override the adapt_population_size method.
Parameters:  nr_particles (int) – Number of particles per populations
 nr_samples_per_parameter (int, optional) – Number of samples to draw for a proposed parameter. Default is 1.

adapt_population_size
(transitions: List[pyabc.transition.base.Transition], model_weights: numpy.ndarray)¶ Select the population size for the next population.
Parameters:  transitions (List of Transitions) –
 model_weights (array of model weights) –
Returns: n – The new population size
Return type: int

get_config
()¶ Get the configuration of this object.
Returns: Configuration of the class as dictionary Return type: dict

to_json
()¶ 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: str

class
pyabc.populationstrategy.
ConstantPopulationSize
(nr_particles: int, *, nr_samples_per_parameter: int = 1)¶ Constant size of the different populations
Parameters:  nr_particles (int) – Number of particles per populations
 nr_samples_per_parameter (int) – Number of samples to draw for a proposed parameter

adapt_population_size
(transitions, model_weights)¶ Select the population size for the next population.
Parameters:  transitions (List of Transitions) –
 model_weights (array of model weights) –
Returns: n – The new population size
Return type: int

class
pyabc.populationstrategy.
AdaptivePopulationSize
(start_nr_particles, mean_cv=0.05, *, max_population_size=inf, min_population_size=10, nr_samples_per_parameter=1)¶ 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 selection 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 (int) – Number of particles in the first populations
 mean_cv (float, optional) – 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 (int, optional) – Max nr of allowed particles in a population. Defaults to infinity.
 min_population_size (int, optional) – Min number of particles allowed in a population. Defaults to 10
 nr_samples_per_parameter (int, optional) – Defaults to 1.
[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/9783319674711_8. 
adapt_population_size
(transitions: List[pyabc.transition.base.Transition], model_weights: numpy.ndarray)¶ Select the population size for the next population.
Parameters:  transitions (List of Transitions) –
 model_weights (array of model weights) –
Returns: n – The new population size
Return type: int

get_config
()¶ Get the configuration of this object.
Returns: Configuration of the class as dictionary Return type: dict