mixle.ppl.summarize module

Posterior summarization for the mixle PPL: highest-density intervals and an ArviZ-style table.

After an MCMC / ensemble fit you want a compact, readable report of each parameter’s posterior. The equal-tailed credible interval in RandomVariable.summary() is fine for symmetric posteriors; hdi() gives the highest-density interval (the narrowest interval holding the mass, the right choice for skewed or bounded posteriors), and posterior_summary() assembles the mean / sd / HDI together with the convergence diagnostics (effective sample size, R-hat) into one per-parameter dict.

hdi(samples, prob=0.94)[source]

Highest-density interval: the narrowest interval containing prob of the posterior mass.

For a unimodal posterior this is the shortest (low, high) such that P(low <= x <= high) = prob; unlike an equal-tailed interval it tracks an asymmetric or bounded posterior correctly.

Parameters:
Return type:

tuple[float, float]

posterior_summary(fitted, *, hdi_prob=0.94)[source]

Per-parameter posterior summary table for a fitted PPL model (best after how='mcmc').

Returns {param_name: {'mean', 'sd', 'hdi_low', 'hdi_high', 'ess', 'r_hat'}}. mean/sd come from the fit’s own summary; the HDI is computed from the posterior draws (when the fit exposes them); ess (effective sample size) and r_hat (Gelman-Rubin, multi-chain) come from the sampler’s diagnostics when present. A point fit (em/map) yields just mean/sd.

Parameters:
  • fitted (RandomVariable)

  • hdi_prob (float)

Return type:

dict[str, dict[str, Any]]