pub struct Experiment { /* private fields */ }Expand description
A sequential non-inferiority experiment between two arms. Pure and deterministic: the same outcome stream always yields the same decision, so a report can be re-derived from receipts.
Implementations§
Source§impl Experiment
impl Experiment
Sourcepub fn new(margin: f64, alpha: f64) -> Result<Self, String>
pub fn new(margin: f64, alpha: f64) -> Result<Self, String>
A new experiment with no evidence.
§Errors
If margin is not in (0, 0.5] or alpha is not in (0, 0.5). A zero margin can never
certify and a margin above half is not a quality bar; an alpha of a half or more is a coin.
Sourcepub fn observe_outcome(&mut self, arm: Arm, outcome: f64) -> bool
pub fn observe_outcome(&mut self, arm: Arm, outcome: f64) -> bool
Record one session’s outcome in [0, 1] (1 = the task succeeded).
Returns false and records nothing if outcome is not a finite value in [0, 1]: an
out-of-range value would break the nonnegativity the guarantee rests on, and clamping it
would silently change what the caller reported.
Sourcepub fn observe_pair(&mut self, x_inc: f64, x_ch: f64) -> bool
pub fn observe_pair(&mut self, x_inc: f64, x_ch: f64) -> bool
Record a paired observation directly, bypassing the FIFO queues.
In paired shadow mode both the incumbent’s and the challenger’s gate verdicts for the same
request are known simultaneously and arrive as a complete unit. The FIFO pairing is
unnecessary in that case — its buffering semantics would make the arrival order depend on
which arm returns first — so this method steps the e-process directly with D = x_inc − x_ch.
Returns false if either value is not a finite f64 in [0, 1]: an out-of-range value
would break the nonnegativity the guarantee rests on, and clamping would silently alter what
the caller reported. Abstaining on either side (passing None to the caller’s wrapper)
should drop the pair before calling this; here only fully resolved values are accepted.
Sourcepub fn observe_cost(&mut self, arm: Arm, cost_usd: f64)
pub fn observe_cost(&mut self, arm: Arm, cost_usd: f64)
Record the cost of one request served by arm. Negative or non-finite costs are ignored.