SamplesSummary

Contents

SamplesSummary#

class liesel.goose.SamplesSummary(samples, quantiles=(0.05, 0.5, 0.95), hdi_prob=0.9, selected=None, deselected=None, per_chain=False, which=('mean', 'sd', 'var', 'quantiles', 'hdi', 'ess_bulk', 'ess_tail', 'rhat', 'mcse_mean', 'mcse_sd'))[source]#

Bases: object

Posterior summary and diagnostics for a dictionary of sample arrays.

Accepts read-only mappings and does not modify the supplied mapping or its arrays.

See Summary for the full description of the computed statistics, their interpretation, the quantities layout, and the behavior of quantiles, hdi_prob, per_chain, and which. This class computes the same sample-based statistics as Summary, but takes a plain dictionary of sample arrays instead of a SamplingResults object and does not include sampling-error or acceptance-probability diagnostics.

Offers two main use cases:

  1. The summary object can be turned into a DataFrame

    using to_dataframe().

  2. Programmatically access summary statistics via quantities[quantity_name][var_name]. Please refer to the documentation of the attribute quantities for details.

Parameters:
  • samples (Mapping[str, ArrayLike]) – The dictionary of samples to summarize. Each array is expected to have leading dimensions (nchains, ndraws, ...).

  • quantiles (Sequence[float], default: (0.05, 0.5, 0.95)) – Posterior quantile probabilities to compute when "quantiles" is included in which.

  • hdi_prob (float, default: 0.9) – Posterior probability mass of the highest density interval to compute when "hdi" is included in which.

  • selected (list[str] | None, default: None) – Allow to get a summary only for a subset of the position keys.

  • deselected (list[str] | None, default: None) – Allow to get a summary only for a subset of the position keys.

  • per_chain (bool, default: False) – If True, the summary is calculated on a per-chain basis. Certain measures like rhat are not available if per_chain is True.

  • which (Sequence[Literal['mean', 'sd', 'var', 'quantiles', 'hdi', 'ess_bulk', 'ess_tail', 'rhat', 'mcse_mean', 'mcse_sd']], default: ('mean', 'sd', 'var', 'quantiles', 'hdi', 'ess_bulk', 'ess_tail', 'rhat', 'mcse_mean', 'mcse_sd')) – Names of the summary statistics to compute. Supported values are the same as for Summary.

Notes

This class is still considered experimental. The API may still undergo larger changes.

Methods

aggregate_diagnostics([by])

Aggregates effective sample sizes (ESS) and rhat.

from_array(a[, quantiles, hdi_prob, ...])

Initializes the summary from an array of samples.

to_dataframe()

Turns SamplesSummary object into a DataFrame object.

Attributes

config

Configuration used to compute and format the summaries.

per_chain

Whether summaries are computed separately for each chain.

quantities

Computed summary quantities for the selected samples.

sample_info

Metadata describing the chains and posterior draws.