_AbstractSampler#

class hmclab.Samplers._AbstractSampler(seed: Optional[int] = None)[source]#

Bases: abc.ABC

Abstract base class for Markov chain Monte Carlo samplers.

__init__(seed: Optional[int] = None) None[source]#

Constructor that sets the random number generator for the sampler. Pass a seed to make a Markov chain reproducible (given that all settings are re-used.)

Parameters

seed (int) – Description of parameter seed.

Methods

__init__

Constructor that sets the random number generator for the sampler.

get_diagnostics

load_results

print_results

Print Jupyter widget from _repr_html_() to stdout.

Attributes

accepted_proposals

An integer representing the amount of accepted proposals.

amount_of_writes

A positive integer representing the amount of times the sampler has written to disk.

current_model

A NumPy array containing the model at the current state of the Markov chain.

current_proposal

An integer representing the current proposal index (before thinning) of the Markov chain.

current_proposal_after_thinning

An integer representing the current proposal index after thinning of the Markov chain.

current_x

A float containing \(\chi = -\log\left( p\\right)\) (i.e.

diagnostic_mode

Boolean describing whether functions need to be profiled for performance.

dimensions

An integer representing the dimensionality in which the MCMC sampler works.

disable_progressbar

A bool describing whether or not to disable the TQDM progressbar

distribution

The _AbstractDistribution-derived object on which the sampler works.

end_time

Time (and date) at which sampling was terminated / finished.

exchange_interval

Integer describing how many samples lie between the attempted swap of states between samplers.

exchange_schedule

A pre-communicated exchange schedule determining when and which samplers try to exchange states.

functions_to_diagnose

Array of functions to be profiled, typically contains functions only from the abstract base class.

main_thread_keyboard_interrupt

max_time

A float representing the maximum time in seconds that sampling is allowed to take before it is automatically terminated.

name

The name of the sampler

online_thinning

An integer representing the interval between stored samples.

parallel

A boolean describing if this sampler works in an array of multiple samplers.

pipe_matrix

A matrix of two-way communicators between samplers.

progressbar_refresh_rate

A float representing how many seconds lies between an update of the progress bar statistics (acceptance rate etc.).

proposals

An integer representing the amount of requested proposals for a run.

proposed_model

A NumPy array containing the model at the proposed state of the Markov chain.

proposed_x

A float containing \(\chi = -\log\left( p\\right)\) (i.e.

ram_buffer

A NumPy ndarray containing the samples that are as of yet not written to disk.

ram_buffer_size

A positive integer indicating the size of the RAM buffer in amount of samples.

rng

sampler_index

An integer describing the index of the parallel sampler in the array of samplers.

sampler_specific_functions_to_diagnose

Array of sampler specific functions to be profiled.

samples_hdf5_dataset

A string containing the HDF5 group of the hdf5 file to which samples will be stored.

samples_hdf5_filehandle

A HDF5 file handle of the hdf5 file to which samples will be stored.

samples_hdf5_filename

A string containing the path+filename of the hdf5 file to which samples will be stored.

start_time

Time (and date) at which sampling was started.

times_started

An integer representing how often this sampler object has started sampling.

name: str = 'Monte Carlo sampler abstract base class'#

The name of the sampler

dimensions: int = None#

An integer representing the dimensionality in which the MCMC sampler works.

distribution: hmclab.Distributions.base._AbstractDistribution = None#

The _AbstractDistribution-derived object on which the sampler works.

samples_hdf5_filename: str = None#

A string containing the path+filename of the hdf5 file to which samples will be stored.

samples_hdf5_filehandle = None#

A HDF5 file handle of the hdf5 file to which samples will be stored.

samples_hdf5_dataset = None#

A string containing the HDF5 group of the hdf5 file to which samples will be stored.

ram_buffer_size: int = None#

A positive integer indicating the size of the RAM buffer in amount of samples.

ram_buffer: numpy.ndarray = None#

A NumPy ndarray containing the samples that are as of yet not written to disk.

current_model: numpy.ndarray = None#

A NumPy array containing the model at the current state of the Markov chain.

proposed_model: numpy.ndarray = None#

A NumPy array containing the model at the proposed state of the Markov chain.

current_x: float = None#

A float containing \(\chi = -\log\left( p\\right)\) (i.e. the misfit, negative log probability) of the distribution at the current state of the Markov chain.

proposed_x: float = None#

A float containing \(\chi = -\log\left( p\\right)\) (i.e. the misfit, negative log probability) of the distribution at the proposed state of the Markov chain.

amount_of_writes: int = None#

A positive integer representing the amount of times the sampler has written to disk.

progressbar_refresh_rate: float = 0.25#

A float representing how many seconds lies between an update of the progress bar statistics (acceptance rate etc.).

max_time: float = None#

A float representing the maximum time in seconds that sampling is allowed to take before it is automatically terminated. The value None is used for unlimited time.

times_started: int = 0#

An integer representing how often this sampler object has started sampling.

proposals: int = None#

An integer representing the amount of requested proposals for a run.

online_thinning: int = None#

An integer representing the interval between stored samples. Defaults to 1, i.e. all samples are stored.

current_proposal: int = 0#

An integer representing the current proposal index (before thinning) of the Markov chain.

current_proposal_after_thinning: int = 0#

An integer representing the current proposal index after thinning of the Markov chain.

accepted_proposals: int = 0#

An integer representing the amount of accepted proposals.

disable_progressbar: bool = False#

A bool describing whether or not to disable the TQDM progressbar

end_time: datetime.datetime = None#

Time (and date) at which sampling was terminated / finished.

start_time: datetime.datetime = None#

Time (and date) at which sampling was started.

diagnostic_mode: bool = True#

Boolean describing whether functions need to be profiled for performance.

functions_to_diagnose: List = []#

Array of functions to be profiled, typically contains functions only from the abstract base class.

sampler_specific_functions_to_diagnose: List = []#

Array of sampler specific functions to be profiled.

parallel: bool = False#

A boolean describing if this sampler works in an array of multiple samplers.

sampler_index: int = 0#

An integer describing the index of the parallel sampler in the array of samplers. Essential for two-way communication.

exchange_schedule = None#

A pre-communicated exchange schedule determining when and which samplers try to exchange states.

pipe_matrix = None#

A matrix of two-way communicators between samplers. Indexed using sampler_index.

exchange_interval: int = None#

Integer describing how many samples lie between the attempted swap of states between samplers.

print_results() None[source]#

Print Jupyter widget from _repr_html_() to stdout.