Expand description
Value-of-Information (VOI) Sampling Policy for expensive measurements.
This module decides when to sample costly latency/cost measurements so overhead stays low while guarantees remain intact.
§Mathematical Model
We treat “violation” observations as Bernoulli random variables:
X_t ∈ {0,1}, X_t = 1 ⇔ measurement violates SLA thresholdWe maintain a Beta prior/posterior over the violation probability p:
p ~ Beta(α, β)
α ← α + X_t
β ← β + (1 − X_t)The posterior variance is:
Var[p] = αβ / ((α+β)^2 (α+β+1))§Expected VOI (Variance Reduction)
The expected variance after one more sample is:
E[Var[p] | one sample] =
p̂ · Var[Beta(α+1,β)] + (1−p̂) · Var[Beta(α,β+1)]where p̂ = α / (α+β) is the posterior mean.
The value of information (VOI) is the expected reduction:
VOI = Var[p] − E[Var[p] | one sample] ≥ 0§Anytime-Valid Safety (E-Process Layer)
We optionally track an e-process over the same Bernoulli stream to keep decisions anytime-valid. Sampling decisions depend only on past data, so the e-process remains valid under adaptive sampling:
W_0 = 1
W_t = W_{t-1} × (1 + λ (X_t − μ₀))where μ₀ is the baseline violation rate under H₀ and λ is a betting
fraction (clamped for stability).
§Decision Rule (Explainable)
We compute a scalar score:
score = VOI × value_scale × (1 + boundary_weight × boundary_score)
boundary_score = 1 / (1 + |log W − log W*|)where W* = 1/α is the e-value threshold.
Then:
- If
max_intervalexceeded ⇒ sample (forced). - If
min_intervalnot met ⇒ skip (guard). - Else sample iff
score ≥ cost.
This yields a deterministic, explainable policy that preferentially samples when uncertainty is high and evidence is near the decision boundary.
§Perf JSONL Schema
The microbench emits JSONL lines per decision:
{"test":"voi_sampling","case":"decision","idx":N,"elapsed_ns":N,"sample":true,"violated":false,"e_value":1.23}§Key Invariants
- Deterministic: same inputs → same decisions.
- VOI non-negative: expected variance reduction ≥ 0.
- Anytime-valid: e-process remains valid under adaptive sampling.
- Bounded silence: max-interval forces periodic sampling.
§Failure Modes
| Condition | Behavior | Rationale |
|---|---|---|
| α,β ≤ 0 | Clamp to ε | Avoid invalid Beta |
| μ₀ ≤ 0 or ≥ 1 | Clamp to (ε, 1−ε) | Avoid degenerate e-process |
| λ out of range | Clamp to valid range | Prevent negative wealth |
| cost ≤ 0 | Clamp to ε | Avoid divide-by-zero in evidence |
| max_interval = 0 | Disabled | Explicit opt-out |
§Usage
use ftui_runtime::voi_sampling::{VoiConfig, VoiSampler};
use std::time::Instant;
let mut sampler = VoiSampler::new(VoiConfig::default());
let decision = sampler.decide(Instant::now());
if decision.should_sample {
let violated = false; // measure and evaluate
sampler.observe(violated);
}Structs§
- VoiConfig
- Configuration for the VOI sampling policy.
- VoiDecision
- Sampling decision with full evidence.
- VoiObservation
- Observation result after a sample is taken.
- VoiSampler
- VOI-driven sampler with Beta-Bernoulli posterior and e-process control.
- VoiSampler
Snapshot - Snapshot of VOI sampler state for debug overlays.
- VoiSummary
- Summary statistics for VOI sampling.
Enums§
- VoiLog
Entry - Log entry for VOI sampling.