Rank Statistics and Uniformity

Summary

The core SBC theorem: if a prior draw and its posterior sample come from a correctly computed analysis, then the rank of any one-dimensional function of among the posterior values is uniformly distributed over the integers . This converts the data-averaged posterior identity into a sharp, artifact-free, integer-valued test of computational correctness.

Overview

Cook, Gelman & Rubin (2006) tested an empirical CDF value, which is continuous-in-principle but discrete in practice and prone to boundary artifacts. SBC instead tests a rank statistic, which is inherently integer-valued and admits an exact uniform distribution under correct computation — no continuity correction or asymptotics required. This sidesteps the discretization and central-limit-theorem problems described in Simulation-Based Calibration - Overview.

Main Content

Consider one iteration of the generative-then-fit process:

By the self-consistency identity (see Data-Averaged Posterior Self-Consistency), the prior draw and an exact posterior sample are distributed according to the same distribution.

Rank statistic (Eq. 4.1)

For any one-dimensional random variable / test function , the rank statistic of the prior draw relative to the posterior sample is the number of posterior values whose -image falls below the prior draw’s:

Here is the number of posterior draws, the -th posterior draw, the prior draw (ground truth), and the indicator. There are possible rank values (the prior draw can fall in any of the gaps among the ordered posterior values).

Theorem 1 — Uniformity of the rank statistic

Let , , and for any joint distribution . Then the rank statistic of any one-dimensional random variable over is uniformly distributed over the integers (i.e. each of the values has probability ). Conditions (made explicit in Appendix B / Theorem 2): the posterior draws must be sampled independently from the exact posterior (the proof uses order statistics and assumes independence); the pushforward posterior densities must be absolutely continuous (no ties). Both independence and correct (exact) sampling are required — violating either breaks uniformity, which is exactly what makes deviations diagnostic.

Proof sketch (Appendix B). Relabel the posterior draws so (with , ). Writing the PMF of the rank via the multinomial/order-statistic combinatorial factor and the events , , one uses that conditioning on makes the posterior draws independent of the conditioning configuration, , and crucially that the model used to simulate the data is the same as the one used to fit it, so (the posterior draw and the prior draw share a distribution given ). Substituting the probability-integral change of variables collapses the inner integral to (a Beta integral). The combinatorial prefactor cancels it, leaving

uniform over the ranks.

Why ranks, not CDF values. The rank is integer-valued by construction, so the uniform distribution is discrete uniform on — exact and finite-sample, with no -at-0-or-1 boundary problem and no continuity correction (contrast Cook, Gelman & Rubin 2006 / Blom 1958).

Examples

Multidimensional models

Setup: has many components. Result: compute a separate rank statistic (and histogram) for each one-dimensional function of interest — e.g. each parameter, or a derived quantity like a regional average. Interpretation: because the theorem holds for any one-dimensional , SBC can target inferentially important summaries; the procedure is simply repeated per quantity (see The SBC Algorithm).

Correct sampler → uniform ranks

Setup: Stan (dynamic HMC) on a linear regression, . Result: the rank histogram is consistent with discrete uniform within the expected variation (Fig. 2). Interpretation: confirms correct posterior sampling — the opposite of the spurious deviations the old CDF-based procedure produced on the same model (Fig. 1).

Connections

See Also