Skip to main content

Module psis

Module psis 

Source
Expand description

Pareto-smoothed importance-sampling utilities.

The implementation is intentionally self-contained: it estimates the generalized-Pareto tail shape k from the largest positive weights and replaces only that empirical tail by monotone GPD expected quantiles. The returned k_hat has the usual GPD tail interpretation: values near zero indicate light tails, k > 0.5 indicates that the fitted tail has infinite variance, and larger values mark increasingly unstable upper tails. Consumers decide whether that tail is a draw-wise PSIS reliability diagnostic or another influence diagnostic based on what the supplied weights represent.

The shape is recovered with the Zhang–Stephens (2009) empirical-Bayes profile estimator — the same GPD tail fit used by loo/ArviZ for draw-wise PSIS diagnostics. Crucially it is consistent across the entire k ∈ (−∞, ∞) range, including the dangerous k ≥ 0.5 regime where the GPD variance is infinite and the older method-of-moments form k = ½(1 − μ²/Var) is structurally capped below 0.5 and so cannot fire a heavy-tail gate.

Structs§

PsisResult

Constants§

MIN_TAIL_COUNT

Functions§

fit_gpd_moments
Fit a generalized-Pareto distribution 1 − (1 + k·x/σ)^(−1/k) to positive excesses with the Zhang–Stephens (2009) empirical-Bayes profile estimator.
pareto_smooth_weights
Pareto-smooth a non-negative weight vector and report the fitted GPD tail shape. Non-tail observations are left bit-identical; only the largest tail observations are replaced by sorted GPD expected quantiles and then clipped to be non-decreasing in the original sorted order.