pub struct BayesianConfidenceUpdater { /* private fields */ }Expand description
Bayesian confidence updater using a Beta-Bernoulli conjugate model.
§Model
Maintains parameters (α, β) of a Beta distribution. On each observation:
- Success:
α += 1 - Failure:
β += 1
The posterior mean α / (α + β) is used as the point estimate.
Implementations§
Source§impl BayesianConfidenceUpdater
impl BayesianConfidenceUpdater
Sourcepub fn with_builtin_prior() -> Self
pub fn with_builtin_prior() -> Self
Create an updater with the builtin_priors() prior.
Sourcepub fn update_success(&mut self)
pub fn update_success(&mut self)
Record a success observation (α += 1).
Sourcepub fn update_failure(&mut self)
pub fn update_failure(&mut self)
Record a failure observation (β += 1).
Sourcepub fn posterior_mean(&self) -> f32
pub fn posterior_mean(&self) -> f32
Posterior mean: α / (α + β).
Sourcepub fn posterior_variance(&self) -> f32
pub fn posterior_variance(&self) -> f32
Posterior variance: αβ / ((α+β)²(α+β+1)).
Sourcepub fn sample_count(&self, prior: &BetaPrior) -> u32
pub fn sample_count(&self, prior: &BetaPrior) -> u32
Total observations recorded above the prior (i.e. (α - α₀) + (β - β₀)).
Sourcepub fn snapshot(&self, prior: &BetaPrior) -> ConfidenceSnapshot
pub fn snapshot(&self, prior: &BetaPrior) -> ConfidenceSnapshot
Build a ConfidenceSnapshot from the current posterior state.
prior is used only to compute sample_count; pass builtin_priors()
unless you constructed this updater with a custom prior.
Auto Trait Implementations§
impl Freeze for BayesianConfidenceUpdater
impl RefUnwindSafe for BayesianConfidenceUpdater
impl Send for BayesianConfidenceUpdater
impl Sync for BayesianConfidenceUpdater
impl Unpin for BayesianConfidenceUpdater
impl UnsafeUnpin for BayesianConfidenceUpdater
impl UnwindSafe for BayesianConfidenceUpdater
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