pub struct ExperimentRunner {
pub experiments: HashMap<String, ExperimentState>,
/* private fields */
}Expand description
Manages multiple A/B experiments.
Fields§
§experiments: HashMap<String, ExperimentState>Implementations§
Source§impl ExperimentRunner
impl ExperimentRunner
Sourcepub fn create_experiment(&mut self, config: ExperimentConfig) -> String
pub fn create_experiment(&mut self, config: ExperimentConfig) -> String
Register an experiment and return its generated ID.
Sourcepub fn assign_variant<'a>(
&'a self,
experiment_id: &str,
user_id: &str,
) -> Option<&'a ExperimentVariant>
pub fn assign_variant<'a>( &'a self, experiment_id: &str, user_id: &str, ) -> Option<&'a ExperimentVariant>
Consistently assign a variant to a user using FNV1a hashing.
Sourcepub fn record_metric(
&mut self,
experiment_id: &str,
variant_name: &str,
value: f64,
)
pub fn record_metric( &mut self, experiment_id: &str, variant_name: &str, value: f64, )
Record a metric value for a variant.
Sourcepub fn welch_t_test(a: &[f64], b: &[f64]) -> f64
pub fn welch_t_test(a: &[f64], b: &[f64]) -> f64
Run Welch’s t-test between two samples. Returns the two-tailed p-value approximated via the normal CDF.
Sourcepub fn cohen_d(a: &[f64], b: &[f64]) -> f64
pub fn cohen_d(a: &[f64], b: &[f64]) -> f64
Cohen’s d effect size: (mean_a - mean_b) / pooled_std
Sourcepub fn analyze_experiment(
&self,
experiment_id: &str,
) -> Option<SignificanceTest>
pub fn analyze_experiment( &self, experiment_id: &str, ) -> Option<SignificanceTest>
Pairwise comparison of control (first variant) vs all others.
Sourcepub fn experiment_report(&self, experiment_id: &str) -> Option<String>
pub fn experiment_report(&self, experiment_id: &str) -> Option<String>
Generate a text report for an experiment.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExperimentRunner
impl RefUnwindSafe for ExperimentRunner
impl Send for ExperimentRunner
impl Sync for ExperimentRunner
impl Unpin for ExperimentRunner
impl UnsafeUnpin for ExperimentRunner
impl UnwindSafe for ExperimentRunner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request