bartz.mcmcloop.Callback¶
- class bartz.mcmcloop.Callback[source]¶
Base class for
run_mcmccallbacks.To subclass: define any state as attributes (this is a dataclass), and override
__call__.- abstractmethod __call__(*, key, state, burnin, i_total, n_burn, n_save, n_skip, i_outer, inner_loop_length)[source]¶
Do an arbitrary action after an iteration of the MCMC.
- Parameters:
key (
Key[Array, '']) – A key for random number generation.state (
State) – The MCMC state just after updating it.burnin (
Bool[Array, '']) – Whether the last iteration was in the burn-in phase.i_total (
Int32[Array, '']) – The index of the last MCMC iteration (0-based).n_burn (
Int32[Array, ''])n_save (
Int32[Array, ''])n_skip (
Int32[Array, '']) – The correspondingrun_mcmcarguments as-is.i_outer (
Int32[Array, '']) – The index of the last outer loop iteration (0-based).inner_loop_length (
Int32[Array, '']) – The number of MCMC iterations in the inner loop.
- Returns:
state (State) – A possibly modified MCMC state. To avoid modifying the state, return the
stateargument passed to the callback as-is.callback (Callback) – The updated callback to be used on the next invocation; use this return value to update any state the callback may need to update.
Notes
For convenience, the callback may return
None, and neither the state nor the callback will be updated.