Skip to main content

Experiment

Struct Experiment 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn status(&self) -> Status

Current decision.

Source

pub fn report(&self) -> Report

A summary of the experiment as it stands.

Trait Implementations§

Source§

impl Clone for Experiment

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Experiment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Experiment

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Experiment

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.