pub struct BetaBernoulliObservation {
pub probability_variable: String,
pub observations: Vec<bool>,
}Expand description
BetaBernoulliObservation captures a Bernoulli likelihood y ~ Bernoulli(p)
where the success probability p is a BetaNP variable. It contributes
(n_s, n_f) to the posterior natural parameters, i.e. adds n_s to
(α − 1) and n_f to (β − 1).
A factor holds a reference to its Beta-distributed probability variable and a (possibly empty) batch of binary outcomes. Posterior inference combining prior + factor is exact in one VMP sweep because Bernoulli is conjugate to Beta.
Fields§
§probability_variable: StringName of the BetaNP variable in the VMP graph.
observations: Vec<bool>Observed binary outcomes (true = success, false = failure).
Implementations§
Source§impl BetaBernoulliObservation
impl BetaBernoulliObservation
Sourcepub fn new(
probability_variable: impl Into<String>,
observations: Vec<bool>,
) -> Self
pub fn new( probability_variable: impl Into<String>, observations: Vec<bool>, ) -> Self
Build a new Beta-Bernoulli observation factor from a boolean batch.
Sourcepub fn from_counts(
probability_variable: impl Into<String>,
successes: u64,
failures: u64,
) -> Self
pub fn from_counts( probability_variable: impl Into<String>, successes: u64, failures: u64, ) -> Self
Convenience constructor from aggregate counts. Often you already have
the sufficient statistics as (n_s, n_f) without keeping the raw batch.
Sourcepub fn num_successes(&self) -> u64
pub fn num_successes(&self) -> u64
Number of successes n_s = Σ 1[y_i = 1]. Used as the α-parameter increment.
Sourcepub fn num_failures(&self) -> u64
pub fn num_failures(&self) -> u64
Number of failures n_f = Σ 1[y_i = 0]. Used as the β-parameter increment.
Sourcepub fn num_observations(&self) -> usize
pub fn num_observations(&self) -> usize
Total number of observations N = n_s + n_f.
Trait Implementations§
Source§impl Clone for BetaBernoulliObservation
impl Clone for BetaBernoulliObservation
Source§fn clone(&self) -> BetaBernoulliObservation
fn clone(&self) -> BetaBernoulliObservation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BetaBernoulliObservation
impl RefUnwindSafe for BetaBernoulliObservation
impl Send for BetaBernoulliObservation
impl Sync for BetaBernoulliObservation
impl Unpin for BetaBernoulliObservation
impl UnsafeUnpin for BetaBernoulliObservation
impl UnwindSafe for BetaBernoulliObservation
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.