Seeded paired cluster bootstrap (Koehn 2004, "Statistical Significance Tests for Machine Translation Evaluation", §6; resampling unit per Miller 2024).
Each replicate draws as many clusters as there are, with replacement, and evaluates a paired statistic on the drawn clusters. Because one draw serves both arms, the candidate–baseline correlation is kept. The cluster is the case, or a group of cases sharing a scenario/template when cases are not independent. Per-case values should already be reduced over the k samples (case means); metrics that are not case means (pass^k, F1, average precision) are recomputed per replicate by a custom statistic.
Determinism
Random draws come only from :rand.uniform_s/2 on an explicit
:rand.seed_s(:exsss, seed) state (never the process dictionary, never
normal_s, whose output is platform-dependent). The algorithm is pinned
to :exsss because :default may change between OTP releases.
Replicates are split into :streams independent streams; stream s
starts from the seeded state advanced by s calls of :rand.jump/1
(2^64 draws each, so streams never overlap). The output depends only on
{seed, resamples, streams}: running the streams concurrently
(:max_concurrency > 1) gives results identical to running them
serially. Persist :seed, :algorithm, :resamples and :streams from
the result with any comparison so it can be reproduced.
Percentile intervals undercover at small n (Bowyer et al. 2025); flag results with few clusters as such.
Summary
Types
One cluster of paired items. With the default :mean_difference
statistic each item is {candidate, baseline} (numbers, e.g. per-case
means); with a custom statistic items can be any term.
A function from the items of the drawn clusters to a number.
Functions
Paired cluster bootstrap of statistic over clusters.
Types
@type cluster() :: [term()]
One cluster of paired items. With the default :mean_difference
statistic each item is {candidate, baseline} (numbers, e.g. per-case
means); with a custom statistic items can be any term.
@type result() :: %{ :estimate => float(), :ci => Nous.Eval.Stats.ci(), :se => float(), :p_le_0 => float(), :p_ge_0 => float(), :clusters => pos_integer(), :resamples => pos_integer(), :streams => pos_integer(), :seed => integer() | {integer(), integer(), integer()}, :algorithm => :exsss, :confidence => float(), optional(:replicates) => [float()] }
A function from the items of the drawn clusters to a number.
Functions
@spec paired_cluster([cluster()], keyword()) :: {:ok, result()} | {:error, :seed_required | :insufficient_clusters | :empty_cluster | :invalid_values | :invalid_confidence | {:invalid_statistic, term()} | {:invalid_option, atom()}}
Paired cluster bootstrap of statistic over clusters.
clusters is a list of clusters; each cluster is a non-empty list of
paired items (see cluster/0). At least two clusters are required.
Options:
:seed- required; an integer or a 3-tuple of integers:resamples- number of replicates B, default10_000:statistic-:mean_difference(default: mean of candidate minus mean of baseline over all drawn items) or a function receiving the flat list of drawn items and returning a number:confidence- percentile interval level, default0.95:streams- number of jumped random streams, default8:max_concurrency- streams evaluated at once, default1(serial, in the calling process); results do not depend on it. A custom statistic runs in task processes when this is above 1.:keep_replicates- include:replicates(in stream order) in the result, defaultfalse
Result keys: :estimate (statistic on the original data), :ci
(type-7 percentiles of the replicates), :se (standard deviation of the
replicates), :p_le_0 / :p_ge_0 (share of replicates <= 0 / >= 0,
the one-sided "no improvement" / "no regression" shares), plus the
reproducibility keys :seed, :algorithm, :resamples, :streams.
Errors: {:error, :seed_required}, {:error, :insufficient_clusters},
{:error, :empty_cluster}, {:error, :invalid_values} (non-numeric
pairs for :mean_difference), {:error, {:invalid_statistic, value}}
when a custom statistic returns a non-number, and
{:error, {:invalid_option, key}}.
Examples
iex> clusters = [[{1.0, 0.0}], [{1.0, 1.0}], [{0.5, 0.0}], [{1.0, 0.5}]]
iex> {:ok, r} = Nous.Eval.Stats.Bootstrap.paired_cluster(clusters, seed: 42, resamples: 200)
iex> {r.estimate, r.resamples, r.algorithm}
{0.5, 200, :exsss}