Expand description
Confidence-from-peakedness: the normative jev-1 derivations over a raw distribution.
Raw distributions are the primary contract; confidence is a derived statistic so that
ecosystem thresholds port (S6a §2.3 — the formulas are normative from the MIT adapter
source and reproduce the docs’ non-stale numeric examples exactly; this crate’s
tests/jev1_compat.rs pins those examples). Whether the upstream service computes the
identical statistic is a live-check item for P0.5/P0.7 (S6a A1) — it changes nothing
here, where confidence is computed from our own distributions.
Nothing in this module is stored in the schema: these are pure functions over the probability vectors that live in the Arrow columns.
Enums§
- Distribution
Error - Why a probability vector is not a valid distribution under the profile.
Constants§
- CONSUMER_
SUM_ TOLERANCE - Consumer-side probability-sum tolerance (D5): readers must accept
|Σp − 1| ≤ 1e-2(“approximately 1” on the wire). - PRODUCER_
SUM_ TOLERANCE - Producer-side probability-sum tolerance (D5): emitted distributions must satisfy
|Σp − 1| ≤ 1e-6. Enforced by batch construction.
Functions§
- argmax_
index - Argmax with the profile tie-break (D6): the earliest index in canonical (insertion)
order wins. Returns
Noneon an empty slice. - check_
distribution - Validate a probability vector against a tolerance. Every component must be a finite
probability in [0, 1] and the sum must be within
toleranceof 1. - choice_
confidence - Choice confidence:
(p_max − 1/n) / (1 − 1/n)— the peak probability scaled against the uniform floor. A single-option distribution is certain by construction (1.0). - confidence
- The normative confidence for any primitive’s distribution. Noul has no confidence
field upstream by design; as a superset convenience it is computed as the choice
formula over the 2-label
[P(false), P(true)]distribution. - expected_
score - The probability-weighted score value
Σᵢ i·pᵢ∈ [0, n−1]. A derived convenience — the trust contract remains the distribution itself. - score_
confidence - Score confidence:
max(0, 1 − MAD_mode / MAD_uniform)whereMAD_mode = Σᵢ pᵢ·|i − argmax|andMAD_uniform = (Σᵢ |i − (n−1)/2|) / n— the distribution’s mean absolute distance from its mode, normalized by the uniform distribution’s mean absolute distance from the center. A single-level distribution is certain by construction (1.0).