pub struct BetaNP {
pub alpha: f64,
pub beta: f64,
}Expand description
Beta distribution stored in (α, β) moment parameterisation.
Natural parameters are η = (α − 1, β − 1). Both α and β must be strictly
positive and finite for the distribution to be well-defined; the constructor
and ExponentialFamily::set_natural reject values outside that open
positive quadrant.
Fields§
§alpha: f64Shape parameter α > 0.
beta: f64Shape parameter β > 0.
Implementations§
Source§impl BetaNP
impl BetaNP
Sourcepub fn new(alpha: f64, beta: f64) -> Result<Self>
pub fn new(alpha: f64, beta: f64) -> Result<Self>
Construct from moment parameters (α, β). Both must be strictly positive and finite.
Sourcepub fn from_natural(natural: &[f64]) -> Result<Self>
pub fn from_natural(natural: &[f64]) -> Result<Self>
Reconstruct a Beta from natural parameters η = (α − 1, β − 1).
Sourcepub fn expected_x(&self) -> f64
pub fn expected_x(&self) -> f64
Expected value E[x] = α / (α + β).
Sourcepub fn expected_log_x(&self) -> f64
pub fn expected_log_x(&self) -> f64
Expected log value E[log x] = ψ(α) − ψ(α + β).
Sourcepub fn expected_log_1mx(&self) -> f64
pub fn expected_log_1mx(&self) -> f64
Expected log of the complement E[log(1 − x)] = ψ(β) − ψ(α + β).
Sourcepub fn multiply_naturals(&self, other: &BetaNP) -> Result<BetaNP>
pub fn multiply_naturals(&self, other: &BetaNP) -> Result<BetaNP>
Sum the natural parameters of self and other. Corresponds to the
pointwise product of densities: if both priors are Beta on the same
variable, their product is another Beta whose natural parameter is the
sum of the two input natural parameters.
Concretely: α_new = α₁ + α₂ − 1 and β_new = β₁ + β₂ − 1.
Trait Implementations§
Source§impl ExponentialFamily for BetaNP
impl ExponentialFamily for BetaNP
Source§fn family_name(&self) -> &'static str
fn family_name(&self) -> &'static str
Source§fn natural_dim(&self) -> usize
fn natural_dim(&self) -> usize
Source§fn natural_params(&self) -> Vec<f64>
fn natural_params(&self) -> Vec<f64>
Source§fn set_natural(&mut self, new_eta: &[f64]) -> Result<()>
fn set_natural(&mut self, new_eta: &[f64]) -> Result<()>
new_eta. Read moreSource§fn expected_sufficient_statistics(&self) -> Vec<f64>
fn expected_sufficient_statistics(&self) -> Vec<f64>
E_q[u(x)] = ∇_η A(η). Read moreAuto Trait Implementations§
impl Freeze for BetaNP
impl RefUnwindSafe for BetaNP
impl Send for BetaNP
impl Sync for BetaNP
impl Unpin for BetaNP
impl UnsafeUnpin for BetaNP
impl UnwindSafe for BetaNP
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.