bayesbay.BaseMarkovChain

class bayesbay.BaseMarkovChain(id, starting_state, perturbation_funcs, perturbation_weights, log_likelihood, temperature=1, save_dpred=True)

Low-level interface for a Markov Chain.

Instantiation of this class is usually done by BaseBayesianInversion.

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

  • starting_state (Any) – starting state of the current chain

  • perturbation_funcs (List[Callable[[Any], Tuple[Any, Number]]]) – a list of perturbation functions

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

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

  • 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