Struct rv::dist::Gaussian [−][src]
pub struct Gaussian { /* fields omitted */ }
Gaussian / Normal distribution, N(μ, σ) over real values.
Examples
Compute the KL Divergence between two Gaussians.
use rv::prelude::*; let gauss_1 = Gaussian::new(0.1, 2.3).unwrap(); let gauss_2 = Gaussian::standard(); // KL is not symmetric let kl_12 = gauss_1.kl(&gauss_2); let kl_21 = gauss_2.kl(&gauss_1); // ... but kl_sym is because it's the sum of KL(P|Q) and KL(Q|P) let kl_sym = gauss_1.kl_sym(&gauss_2); assert!((kl_sym - (kl_12 + kl_21)).abs() < 1E-12);
Implementations
impl Gaussian
[src]
impl Gaussian
[src]pub fn new(mu: f64, sigma: f64) -> Result<Self, GaussianError>
[src]
pub fn new_unchecked(mu: f64, sigma: f64) -> Self
[src]
Creates a new Gaussian without checking whether the parameters are valid.
pub fn standard() -> Self
[src]
Standard normal
Example
let gauss = Gaussian::standard(); assert_eq!(gauss, Gaussian::new(0.0, 1.0).unwrap());
pub fn mu(&self) -> f64
[src]
pub fn set_mu(&mut self, mu: f64) -> Result<(), GaussianError>
[src]
Set the value of mu
Example
let mut gauss = Gaussian::new(2.0, 1.5).unwrap(); assert_eq!(gauss.mu(), 2.0); gauss.set_mu(1.3).unwrap(); assert_eq!(gauss.mu(), 1.3);
Will error for invalid values
assert!(gauss.set_mu(1.3).is_ok()); assert!(gauss.set_mu(std::f64::NEG_INFINITY).is_err()); assert!(gauss.set_mu(std::f64::INFINITY).is_err()); assert!(gauss.set_mu(std::f64::NAN).is_err());
pub fn set_mu_unchecked(&mut self, mu: f64)
[src]
Set the value of mu without input validation
pub fn sigma(&self) -> f64
[src]
Get sigma parameter
Example
let gauss = Gaussian::new(2.0, 1.5).unwrap(); assert_eq!(gauss.sigma(), 1.5);
pub fn set_sigma(&mut self, sigma: f64) -> Result<(), GaussianError>
[src]
Set the value of sigma
Example
let mut gauss = Gaussian::standard(); assert_eq!(gauss.sigma(), 1.0); gauss.set_sigma(2.3).unwrap(); assert_eq!(gauss.sigma(), 2.3);
Will error for invalid values
assert!(gauss.set_sigma(2.3).is_ok()); assert!(gauss.set_sigma(0.0).is_err()); assert!(gauss.set_sigma(-1.0).is_err()); assert!(gauss.set_sigma(std::f64::INFINITY).is_err()); assert!(gauss.set_sigma(std::f64::NEG_INFINITY).is_err()); assert!(gauss.set_sigma(std::f64::NAN).is_err());
pub fn set_sigma_unchecked(&mut self, sigma: f64)
[src]
Set the value of sigma
Trait Implementations
impl Clone for Gaussian
[src]
impl Clone for Gaussian
[src]fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl ConjugatePrior<f64, Gaussian> for NormalGamma
[src]
impl ConjugatePrior<f64, Gaussian> for NormalGamma
[src]type Posterior = Self
Type of the posterior distribution
type LnMCache = f64
Type of the ln_m
cache
type LnPpCache = (GaussianSuffStat, f64)
Type of the ln_pp
cache
fn posterior(&self, x: &DataOrSuffStat<'_, f64, Gaussian>) -> Self
[src]
fn ln_m_cache(&self) -> Self::LnMCache
[src]
fn ln_m_with_cache(
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, f64, Gaussian>
) -> f64
[src]
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, f64, Gaussian>
) -> f64
fn ln_pp_cache(&self, x: &DataOrSuffStat<'_, f64, Gaussian>) -> Self::LnPpCache
[src]
fn ln_pp_with_cache(&self, cache: &Self::LnPpCache, y: &f64) -> f64
[src]
fn ln_m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn ln_pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
impl ConjugatePrior<f64, Gaussian> for NormalInvChiSquared
[src]
impl ConjugatePrior<f64, Gaussian> for NormalInvChiSquared
[src]type Posterior = Self
Type of the posterior distribution
type LnMCache = f64
Type of the ln_m
cache
type LnPpCache = (GaussianSuffStat, f64)
Type of the ln_pp
cache
fn posterior(&self, x: &DataOrSuffStat<'_, f64, Gaussian>) -> Self
[src]
fn ln_m_cache(&self) -> Self::LnMCache
[src]
fn ln_m_with_cache(
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, f64, Gaussian>
) -> f64
[src]
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, f64, Gaussian>
) -> f64
fn ln_pp_cache(&self, x: &DataOrSuffStat<'_, f64, Gaussian>) -> Self::LnPpCache
[src]
fn ln_pp_with_cache(&self, cache: &Self::LnPpCache, y: &f64) -> f64
[src]
fn ln_m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn ln_pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
impl ConjugatePrior<f64, Gaussian> for NormalInvGamma
[src]
impl ConjugatePrior<f64, Gaussian> for NormalInvGamma
[src]type Posterior = Self
Type of the posterior distribution
type LnMCache = f64
Type of the ln_m
cache
type LnPpCache = (GaussianSuffStat, f64)
Type of the ln_pp
cache
fn posterior(&self, x: &DataOrSuffStat<'_, f64, Gaussian>) -> Self
[src]
fn ln_m_cache(&self) -> Self::LnMCache
[src]
fn ln_m_with_cache(
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, f64, Gaussian>
) -> f64
[src]
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, f64, Gaussian>
) -> f64
fn ln_pp_cache(&self, x: &DataOrSuffStat<'_, f64, Gaussian>) -> Self::LnPpCache
[src]
fn ln_pp_with_cache(&self, cache: &Self::LnPpCache, y: &f64) -> f64
[src]
fn ln_m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn ln_pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn m(&self, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
fn pp(&self, y: &X, x: &DataOrSuffStat<'_, X, Fx>) -> f64
[src]
impl ContinuousDistr<Gaussian> for NormalGamma
[src]
impl ContinuousDistr<Gaussian> for NormalGamma
[src]impl ContinuousDistr<f32> for Gaussian
[src]
impl ContinuousDistr<f32> for Gaussian
[src]impl ContinuousDistr<f64> for Gaussian
[src]
impl ContinuousDistr<f64> for Gaussian
[src]impl GewekeTestable<Gaussian, f64> for NormalGamma
[src]
impl GewekeTestable<Gaussian, f64> for NormalGamma
[src]impl GewekeTestable<Gaussian, f64> for NormalInvChiSquared
[src]
impl GewekeTestable<Gaussian, f64> for NormalInvChiSquared
[src]impl GewekeTestable<Gaussian, f64> for NormalInvGamma
[src]
impl GewekeTestable<Gaussian, f64> for NormalInvGamma
[src]impl HasSuffStat<f32> for Gaussian
[src]
impl HasSuffStat<f32> for Gaussian
[src]type Stat = GaussianSuffStat
fn empty_suffstat(&self) -> Self::Stat
[src]
impl HasSuffStat<f64> for Gaussian
[src]
impl HasSuffStat<f64> for Gaussian
[src]type Stat = GaussianSuffStat
fn empty_suffstat(&self) -> Self::Stat
[src]
impl InverseCdf<f32> for Gaussian
[src]
impl InverseCdf<f32> for Gaussian
[src]impl InverseCdf<f64> for Gaussian
[src]
impl InverseCdf<f64> for Gaussian
[src]impl KlDivergence for Gaussian
[src]
impl KlDivergence for Gaussian
[src]impl QuadBounds for Gaussian
[src]
impl QuadBounds for Gaussian
[src]impl Rv<Gaussian> for NormalGamma
[src]
impl Rv<Gaussian> for NormalGamma
[src]impl Rv<Gaussian> for NormalInvChiSquared
[src]
impl Rv<Gaussian> for NormalInvChiSquared
[src]impl Rv<Gaussian> for NormalInvGamma
[src]
impl Rv<Gaussian> for NormalInvGamma
[src]Auto Trait Implementations
impl RefUnwindSafe for Gaussian
impl RefUnwindSafe for Gaussian
impl UnwindSafe for Gaussian
impl UnwindSafe for Gaussian
Blanket Implementations
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,