pub struct ExponentialFamily {
pub sufficient_stats: Vec<fn(&[f64]) -> f64>,
pub log_partition: fn(&[f64]) -> f64,
}Expand description
An exponential family of distributions.
p(x; θ) = exp(θ · T(x) − A(θ)) where T are sufficient statistics and
A is the log-partition (cumulant generating) function.
Fields§
§sufficient_stats: Vec<fn(&[f64]) -> f64>Sufficient statistic functions T_i(x).
log_partition: fn(&[f64]) -> f64Log-partition function A(θ).
Implementations§
Source§impl ExponentialFamily
impl ExponentialFamily
Sourcepub fn new(
sufficient_stats: Vec<fn(&[f64]) -> f64>,
log_partition: fn(&[f64]) -> f64,
) -> Self
pub fn new( sufficient_stats: Vec<fn(&[f64]) -> f64>, log_partition: fn(&[f64]) -> f64, ) -> Self
Create a new ExponentialFamily.
Sourcepub fn natural_params(&self, theta: &[f64]) -> Vec<f64>
pub fn natural_params(&self, theta: &[f64]) -> Vec<f64>
Evaluate the natural parameters at theta (identity for canonical form).
Sourcepub fn moment_params(&self, theta: &[f64]) -> Vec<f64>
pub fn moment_params(&self, theta: &[f64]) -> Vec<f64>
Compute the moment parameters μ_i = ∂A/∂θ_i by finite difference.
Sourcepub fn kl_divergence(&self, theta1: &[f64], theta2: &[f64]) -> f64
pub fn kl_divergence(&self, theta1: &[f64], theta2: &[f64]) -> f64
KL divergence KL(p_{θ1} ‖ p_{θ2}) = A(θ2) − A(θ1) − (θ2−θ1)·μ1.
Auto Trait Implementations§
impl Freeze for ExponentialFamily
impl RefUnwindSafe for ExponentialFamily
impl Send for ExponentialFamily
impl Sync for ExponentialFamily
impl Unpin for ExponentialFamily
impl UnsafeUnpin for ExponentialFamily
impl UnwindSafe for ExponentialFamily
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
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.