pub struct BetaPosterior {
pub alpha: f64,
pub beta: f64,
pub alpha0: f64,
pub beta0: f64,
}Expand description
Beta distribution posterior for a probability parameter (Beta-Bernoulli).
Models θ ∈ [0, 1] with a Beta(α, β) prior; observing a success increments
α, a failure increments β. The original prior (α₀, β₀) is retained so
that observations can report the true trial count for
any prior, not just the uniform one.
Fields§
§alpha: f64Alpha parameter (prior pseudo-successes + observed successes)
beta: f64Beta parameter (prior pseudo-failures + observed failures)
alpha0: f64Prior alpha (α₀) — retained for correct observation counting.
beta0: f64Prior beta (β₀) — retained for correct observation counting.
Implementations§
Source§impl BetaPosterior
impl BetaPosterior
Sourcepub fn observe_success(&mut self)
pub fn observe_success(&mut self)
Update posterior with a success observation
Sourcepub fn observe_failure(&mut self)
pub fn observe_failure(&mut self)
Update posterior with a failure observation
Sourcepub fn credible_interval(&self, probability: f64) -> (f64, f64)
pub fn credible_interval(&self, probability: f64) -> (f64, f64)
95% credible interval (approximate using normal approximation for large counts)
Sourcepub fn observations(&self) -> f64
pub fn observations(&self) -> f64
Number of observed Bernoulli trials, (α − α₀) + (β − β₀).
This subtracts the stored prior pseudo-counts, so it is correct for any
prior — uniform Beta(1, 1), Jeffreys Beta(0.5, 0.5), or informative.
Trait Implementations§
Source§impl Clone for BetaPosterior
impl Clone for BetaPosterior
Source§fn clone(&self) -> BetaPosterior
fn clone(&self) -> BetaPosterior
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BetaPosterior
impl Debug for BetaPosterior
Auto Trait Implementations§
impl Freeze for BetaPosterior
impl RefUnwindSafe for BetaPosterior
impl Send for BetaPosterior
impl Sync for BetaPosterior
impl Unpin for BetaPosterior
impl UnsafeUnpin for BetaPosterior
impl UnwindSafe for BetaPosterior
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.