pybop.samplers.base_sampler#

Classes#

BaseSampler

Base class for Monte Carlo samplers.

Module Contents#

class pybop.samplers.base_sampler.BaseSampler(log_pdf: pybop.LogPosterior | list[pybop.LogPosterior], x0, chains: int, cov0: numpy.ndarray | float)[source]#

Bases: pybop.CostInterface

Base class for Monte Carlo samplers.

Parameters:
  • log_pdf (pybop.LogPosterior or List[pybop.LogPosterior]) – The posterior or PDF to be sampled.

  • chains (int) – Number of chains to be used.

  • x0 – List-like initial values of the parameters for Monte Carlo sampling.

  • cov0 – The covariance matrix to be sampled.

  • Note (Samplers perform maximisation of the Posterior by default.)

abstractmethod run() numpy.ndarray[source]#

Sample from the posterior distribution.

Returns:

Samples from the posterior distribution.

Return type:

np.ndarray

set_initial_phase_iterations(iterations=250)[source]#

Set the number of iterations for the initial phase of the sampler.

Parameters:

iterations (int) – Number of iterations for the initial phase.

set_max_iterations(iterations=500)[source]#

Set the maximum number of iterations for the sampler.

Parameters:

iterations (int) – Maximum number of iterations.

set_parallel(parallel=False)[source]#

Enable or disable parallel evaluation. Credit: PINTS

Parameters:

parallel (bool or int, optional) – If True, use as many worker processes as there are CPU cores. If an integer, use that many workers. If False or 0, disable parallelism (default: False).

_cov0[source]#
_log_pdf[source]#
_n_chains[source]#
_x0[source]#