bartz.mcmcloop.StatsAccumulator

class bartz.mcmcloop.StatsAccumulator(sums, count)[source]

Running average of the forest diagnostics shown during the MCMC.

When enabled, it sums the per-iteration statistics so a report shows their average over the iterations since the previous report. When disabled it carries no running state and a report shows the latest iteration only.

sums: dict[str, Float32[Array, '']] | None

Running sums of the averaged statistics, or None when disabled.

count: Int32[Array, '']

Number of iterations accumulated since the last reset.

classmethod initial(state, *, enabled)[source]

Create a zeroed accumulator, inert unless enabled.

Return type:

StatsAccumulator

update(state)[source]

Add the latest iteration’s statistics; no-op when disabled.

Return type:

StatsAccumulator

reset_if(cond)[source]

Zero the running sums where cond holds; no-op when disabled.

Return type:

StatsAccumulator

report(state)[source]

Statistics to display: the windowed average if enabled, else the latest.

Return type:

StatsReport