bartz.mcmcloop.PrintCallback

class bartz.mcmcloop.PrintCallback(dot_every, report_every, accumulator)[source]

Progress-printing callback for run_mcmc, create it with from_state.

The callback prints a dot on every iteration, and a longer report periodically.

dot_every: Int32[Array, ''] | None

A dot is printed every dot_every MCMC iterations, None to disable.

report_every: Int32[Array, ''] | None

A one line report is printed every report_every MCMC iterations, None to disable.

accumulator: StatsAccumulator

Running average of the reported statistics, inert unless averaging.

classmethod from_state(state, *, dot_every=1, report_every=100, average=True)[source]

Prepare a progress-printing callback for run_mcmc.

Parameters:
  • state (State) – The MCMC state to use the callback with, used to determine device sharding.

  • dot_every (int | Integer[Array, ''] | None, default: 1) – A dot is printed every dot_every MCMC iterations, None to disable.

  • report_every (int | Integer[Array, ''] | None, default: 100) – A one line report is printed every report_every MCMC iterations, None to disable.

  • average (bool, default: True) – If True, the reported statistics are averaged over the iterations since the previous report; if False, they reflect the current iteration only. Ignored when report_every is None.

Returns:

PrintCallback – A callback to pass as the callback argument of run_mcmc.

Examples

>>> run_mcmc(key, state, ..., callback=PrintCallback.from_state(state, ...))
__call__(*, state, burnin, i_total, n_burn, n_save, n_skip, **_)[source]

Print a dot and/or a report periodically during the MCMC.

Return type:

tuple[State, PrintCallback]