bayesbay.MarkovChain

class bayesbay.MarkovChain(id, parameterization, log_likelihood, perturbation_funcs, perturbation_weights, starting_state=None, temperature=1, saved_dpred=True)

High-level interface for a Markov Chain.

This is a subclass of BaseMarkovChain.

Instantiation of this class is usually done by BayesianInversion.

Parameters:
  • id (Union[int, str]) – an integer or a string representing the ID of the current chain. For display purposes only

  • parameterization (bayesbay.parameterization.Parameterization) – pre-configured parameterization. This includes information about the dimension, parameterization bounds and properties of unknown parameterizations

  • log_likelihood (bayesbay.LogLikelihood) – instance of the bayesbay.LogLikelihood class

  • perturbation_funcs (List[Callable]) – a list of perturbation functions (generated automatically by BayesianInversion from parameterization and log_likelihood)

  • perturbation_weights (List[Number]) – a list of perturbation weights

  • temperature (int, optional) – used to temper the log likelihood, by default 1

Reference Details

current_state
ith_iteration
saved_states

All the states saved so far

statistics
temperature

The current temperature used in the log likelihood ratio

advance_chain(n_iterations=1000, burnin_iterations=0, save_every=100, verbose=True, print_every=100, begin_iteration=None, end_iteration=None)

advance the chain for a given number of iterations

Parameters:
  • n_iterations (int, optional) – the number of iterations to advance, by default 1000

  • burnin_iterations (int, optional) – the iteration number from which we start to save samples, by default 0

  • save_every (int, optional) – the frequency in which we save the samples, by default 100

  • verbose (bool, optional) – whether to print the progress during sampling or not, by default True

  • print_every (int, optional) – the frequency with which we print the progress and information during the sampling, by default 100 iterations

  • begin_iteration (Callable[["BaseMarkovChain"], None], optional) – customized function that’s to be run at before an iteration

  • end_iteration (Callable[["BaseMarkovChain"], None], optional) – customized function that’s to be run at after an iteration

Returns:

the chain itself is returned

Return type:

BaseMarkovChain

print_statistics()

print the statistics about the Markov Chain history, including the number of explored and accepted states for each perturbation, acceptance rates and the current temperature

set_perturbation_funcs(funcs, weights)
update_targets(targets)

back to top