pybop.samplers.base_sampler#

Classes#

BaseSampler

Base class for Monte Carlo samplers.

SamplerOptions

Base options for the sampler.

Module Contents#

class pybop.samplers.base_sampler.BaseSampler(log_pdf: pybop.problems.problem.Problem, options: SamplerOptions | None = None)[source]#

Base class for Monte Carlo samplers.

Parameters:
  • log_pdf (pybop.Problem) – The negative unnormalised posterior distribution.

  • options (SamplerOptions, optional) – Options for the sampler. If None, default options are used.

static default_options() SamplerOptions[source]#

Get the default options for the sampler.

abstractmethod run() pybop._result.SamplingResult[source]#

Sample from the posterior distribution.

Returns:

Samples from the posterior distribution.

Return type:

np.ndarray

set_initial_phase_iterations(iterations: int = 250)[source]#

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

set_max_iterations(iterations: int = 500)[source]#

Set the maximum number of iterations for the sampler.

set_warm_up_iterations(iterations: int = 250)[source]#

Set the number of warm up iterations for the sampler.

_log_pdf[source]#
_options[source]#
_x0[source]#
property cov0: numpy.ndarray[source]#
property log_pdf: pybop.problems.problem.Problem[source]#
property options: SamplerOptions[source]#
property x0: numpy.ndarray[source]#
class pybop.samplers.base_sampler.SamplerOptions[source]#

Base options for the sampler.

n_chains[source]#

The number of chains to concurrently sample from.

Type:

int

cov[source]#

Covariance matrix.

Type:

float | np.ndarray

validate()[source]#

Validate the options.

Raises:

ValueError – If the options are invalid.

cov: float | numpy.ndarray = 0.05[source]#
n_chains: int = 1[source]#