gam_terms/basis/measure_jet_predict.rs
1//! Predict-side measure-jet honesty: the closed-form extrapolation variance
2//! from the frame notes (`docs/measure_jet_frame.md` §5).
3//!
4//! The current Gaussian representers decay off-support toward the parametric
5//! backbone with small posterior variance — confident reversion, which the
6//! honesty contract forbids. The structural fix prices ignorance off the web from the SAME
7//! fitted spectrum that smooths on it: every band level ℓ carries a fitted
8//! amplitude λ̂_ℓ (prior precision of the level's innovations), and a query
9//! that the level-ℓ kernel mass does not cover simply has an UNKNOWN level-ℓ
10//! innovation — prior variance λ̂_ℓ⁻¹, collected in full.
11//!
12//! # The formula (and its algebraic relation to §5)
13//!
14//! With `q̄_ℓ = (Σ_i m_i q_ℓ(c_i)) / (Σ_i m_i)` the web-averaged scale-ℓ
15//! support and `a_ℓ(x★) = min(q_ℓ(x★)/q̄_ℓ, 1)` the scale-correct on-web-ness
16//! weight in `[0, 1]`, let
17//! `ℓ★ = min{ℓ : q_ℓ(x★) ≥ coverage_floor · q̄_ℓ}` be the first covering
18//! level (ε★ = ε_{ℓ★}). Then, for per-level spectra,
19//!
20//! ```text
21//! Var_extrap(x★) = Σ_{ℓ < ℓ★} λ̂_ℓ⁻¹ + Σ_{ℓ ≥ ℓ★} (1 − a_ℓ(x★)) · λ̂_ℓ⁻¹
22//! = Σ_ℓ λ̂_ℓ⁻¹ − Σ_{ℓ: ε_ℓ ≥ ε★} a_ℓ(x★) · λ̂_ℓ⁻¹ .
23//! ```
24//!
25//! The second line is the §5 statement: the total prior ignorance of the
26//! spectrum minus the part the query's coverage recovers — the recovered sum
27//! runs over the covered levels `ε_ℓ ≥ ε★` exactly as written in the charter.
28//! In fused mode the band has one precision, so the same coverage idea reduces
29//! to one charge: `λ_fused⁻¹` if no level clears its floor, otherwise
30//! `(1 − max_ℓ a_ℓ(x★)) · λ_fused⁻¹`.
31//! On-web queries (ε★ = ε_0, a_ℓ ≈ 1 everywhere) recover the full spectrum
32//! and pay ≈ 0 extra; far-off queries recover (almost) nothing and pay the
33//! full Σ_ℓ λ̂_ℓ⁻¹. Levels FINER than the first covering scale get no credit
34//! for stray sub-floor kernel mass: below ε★ the prediction is a jet
35//! extension, not an interpolation, so those innovations are charged as pure
36//! ignorance.
37//!
38//! # Never-covered convention
39//!
40//! If no band level clears the coverage floor (ε★ lies past the band), the
41//! covered set is EMPTY: in per-level mode every level contributes its full
42//! λ̂_ℓ⁻¹ and `Var_extrap = Σ_ℓ λ̂_ℓ⁻¹`; in fused mode the single band
43//! amplitude contributes once. The variance saturates at the spectrum's total
44//! prior ignorance instead of growing without bound, which is the honest
45//! statement: the model's coefficient prior is the only information it ever
46//! claimed about such a point.
47//!
48//! # Monotonicity (the distance-honesty theorem)
49//!
50//! Claim: if `q ≤ q′` pointwise (the support row of the farther query is
51//! nowhere larger), then `Var_extrap(q) ≥ Var_extrap(q′)`.
52//!
53//! Proof. `{ℓ : q_ℓ ≥ coverage_floor · q̄_ℓ} ⊆
54//! {ℓ : q′_ℓ ≥ coverage_floor · q̄_ℓ}` for the scale-specific floors, so
55//! `ℓ★(q) ≥ ℓ★(q′)`. Compare the per-level weights `w_ℓ`:
56//! - `ℓ < ℓ★(q′)`: both weights are 1;
57//! - `ℓ ≥ ℓ★(q)`: `w_ℓ(q) = 1 − a_ℓ(q) ≥ 1 − a_ℓ(q′) = w_ℓ(q′)`;
58//! - `ℓ★(q′) ≤ ℓ < ℓ★(q)`: `w_ℓ(q) = 1 ≥ 1 − a_ℓ(q′) = w_ℓ(q′)`.
59//! Every weight is no smaller and every `λ̂_ℓ⁻¹ > 0`, so the sum is no
60//! smaller. ∎
61//!
62//! Since the Gaussian kernel mass `q_ℓ(x★)` is pointwise nonincreasing as
63//! `x★` recedes from every center simultaneously, intervals widen
64//! monotonically with distance from the web. The ε★ gate introduces the only
65//! discontinuity, and it is bounded: a level crossing the floor changes its
66//! weight by at most `a_ℓ ≤ coverage_floor`, so the total jump is at most
67//! `coverage_floor · Σ_ℓ λ̂_ℓ⁻¹` and vanishes as the floor tightens.
68//!
69//! # Units
70//!
71//! The result is on the scale of physical `λ̂⁻¹`: callers must unnormalize the
72//! fitted Frobenius-normalized precision first (`λ_phys = λ_tilde / c`). Family
73//! dispersion scaling remains outside this pure spectrum-side kernel.
74
75#[derive(Clone, Copy)]
76pub enum MeasureJetExtrapolationSpectrum<'a> {
77 /// One physical precision per band level.
78 PerLevel(&'a [f64]),
79 /// One physical precision for the fused band. It is charged once, with the
80 /// band's best coverage fraction.
81 Fused(f64),
82}
83