pub struct SequentialBoundary { /* private fields */ }Expand description
The always-valid boundary of a sequential test with a fixed error budget (spec 3.5 §7.12).
For an estimate with standard error se after n effective units, the boundary rejects
“no difference” when |z| = |estimate / se| reaches critical_z(n),
z*(n)² = (1 + ρ²n) / (ρ²n) · (2 ln(1/α) + ln(1 + ρ²n)),the inversion of the normal-mixture likelihood ratio
Λ = (1 + ρ²n)^(−1/2) · exp(ρ²n·z² / (2(1 + ρ²n))). Under no difference Λ is a nonnegative
martingale starting at 1, so by Ville’s inequality it ever reaches 1/α with probability at
most α, however many looks are taken. estimate ± z*(n)·se is the matching confidence
sequence: it covers the true difference at every look at once with probability at least
1 − α.
ρ is fixed before the first look from the planned effective units m:
ρ² = (2 ln(1/α) + ln(1 + 2 ln(1/α))) / m, which makes the boundary tightest near m.
It changes power, never validity.
§Example
use adk_eval::experiments::SequentialBoundary;
// 10,000 planned units per arm are 5,000 effective units.
let boundary = SequentialBoundary::new(0.05, 5_000.0).unwrap();
// At the planned size the critical z is 3.04, against 1.96 for one fixed-sample look.
assert!((boundary.critical_z(5_000.0) - 3.0352).abs() < 1e-4);
// A z on the boundary has an always-valid p-value equal to α.
let z = boundary.critical_z(1_200.0);
assert!((boundary.p_value(z, 1_200.0) - 0.05).abs() < 1e-12);Implementations§
Source§impl SequentialBoundary
impl SequentialBoundary
Sourcepub fn new(alpha: f64, planned_effective_units: f64) -> Result<Self>
pub fn new(alpha: f64, planned_effective_units: f64) -> Result<Self>
Creates the boundary for budget alpha, tightest at planned_effective_units.
§Errors
Returns EvalError::ConfigError when alpha is outside (0, 1) or the planned size
is not a positive finite number.
Sourcepub fn mixing_rate(&self) -> f64
pub fn mixing_rate(&self) -> f64
Returns ρ², the mixing rate per effective unit.
Sourcepub fn critical_z(&self, effective_units: f64) -> f64
pub fn critical_z(&self, effective_units: f64) -> f64
Returns the critical |z| after effective_units; infinite with no units.