ess_tail#

cultivars.bayes.chains.ess_tail(*chains)[source]#

Tail effective sample size, for credible-interval endpoints.

A sampler that mixes well in the centre of a posterior can still mix poorly in its tails, and the bulk size cannot see it. The tail size is the smaller of the effective sample sizes of the two indicators

\[\mathbb{1}\{x_s \le q_{0.05}\}, \qquad \mathbb{1}\{x_s \le q_{0.95}\},\]

where \(q_{0.05}\) and \(q_{0.95}\) are the quantiles of the pooled draws, each computed on the split chains by the same Geyer estimator as ess_bulk(). The Monte Carlo error of a quantile is governed by the effective size of its indicator, so this is the size that says how well the endpoints of a 90% interval are determined.

Parameters:

*chains (ArrayLike) – One or more (S,) or (S, d) chains of the same shape, with S at least eight and finite throughout.

Return type:

float | NDArray[double]

Returns:

A float for (S,) chains, else (d,); the total across chains. nan for a quantity that never moved.

Raises:

See also

ess_bulk(): The size for means and medians.

References

Vehtari, A., Gelman, A., Simpson, D., Carpenter, B., & Bürkner,

P.-C. (2021). Rank-normalization, folding, and localization: An improved \(\widehat{R}\) for assessing convergence of MCMC. Bayesian Analysis, 16(2), 667-718.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(3)
>>> float(ess_tail(rng.standard_normal(2000))) > 800
True