_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
Constructor that sets the random number generator for the sampler.
get_diagnostics
load_results
Print Jupyter widget from _repr_html_() to stdout.
Attributes
An integer representing the amount of accepted proposals.
A positive integer representing the amount of times the sampler has written to disk.
A NumPy array containing the model at the current state of the Markov chain.
An integer representing the current proposal index (before thinning) of the Markov chain.
An integer representing the current proposal index after thinning of the Markov chain.
A float containing \(\chi = -\log\left( p\\right)\) (i.e.
Boolean describing whether functions need to be profiled for performance.
An integer representing the dimensionality in which the MCMC sampler works.
A bool describing whether or not to disable the TQDM progressbar
The _AbstractDistribution-derived object on which the sampler works.
Time (and date) at which sampling was terminated / finished.
Integer describing how many samples lie between the attempted swap of states between samplers.
A pre-communicated exchange schedule determining when and which samplers try to exchange states.
Array of functions to be profiled, typically contains functions only from the abstract base class.
main_thread_keyboard_interrupt
A float representing the maximum time in seconds that sampling is allowed to take before it is automatically terminated.
The name of the sampler
An integer representing the interval between stored samples.
A boolean describing if this sampler works in an array of multiple samplers.
A matrix of two-way communicators between samplers.
A float representing how many seconds lies between an update of the progress bar statistics (acceptance rate etc.).
An integer representing the amount of requested proposals for a run.
A NumPy array containing the model at the proposed state of the Markov chain.
A float containing \(\chi = -\log\left( p\\right)\) (i.e.
A NumPy ndarray containing the samples that are as of yet not written to disk.
A positive integer indicating the size of the RAM buffer in amount of samples.
rng
An integer describing the index of the parallel sampler in the array of samplers.
Array of sampler specific functions to be profiled.
A string containing the HDF5 group of the hdf5 file to which samples will be stored.
A HDF5 file handle of the hdf5 file to which samples will be stored.
A string containing the path+filename of the hdf5 file to which samples will be stored.
Time (and date) at which sampling was 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.