pub struct InvGaussian { /* private fields */ }Expand description
Inverse Gaussian distribution, N-1(μ, λ) over real values.
Implementations§
Source§impl InvGaussian
impl InvGaussian
Sourcepub fn new(mu: f64, lambda: f64) -> Result<InvGaussian, InvGaussianError>
pub fn new(mu: f64, lambda: f64) -> Result<InvGaussian, InvGaussianError>
Create a new Inverse Gaussian distribution
§Aruments
- mu: mean > 0
- lambda: shape > 0
use rv::dist::InvGaussian;
let invgauss = InvGaussian::new(1.0, 3.0).unwrap();Mu and lambda must be finite and greater than 0.
use std::f64::{NAN, INFINITY};
assert!(InvGaussian::new(0.0, 3.0).is_err());
assert!(InvGaussian::new(NAN, 3.0).is_err());
assert!(InvGaussian::new(INFINITY, 3.0).is_err());
assert!(InvGaussian::new(1.0, 0.0).is_err());
assert!(InvGaussian::new(1.0, NAN).is_err());
assert!(InvGaussian::new(1.0, INFINITY).is_err());Sourcepub fn new_unchecked(mu: f64, lambda: f64) -> InvGaussian
pub fn new_unchecked(mu: f64, lambda: f64) -> InvGaussian
Creates a new InvGaussian without checking whether the parameters are valid.
Sourcepub fn set_mu(&mut self, mu: f64) -> Result<(), InvGaussianError>
pub fn set_mu(&mut self, mu: f64) -> Result<(), InvGaussianError>
Set the value of mu
§Example
let mut ig = InvGaussian::new(2.0, 1.5).unwrap();
assert_eq!(ig.mu(), 2.0);
ig.set_mu(1.3).unwrap();
assert_eq!(ig.mu(), 1.3);Will error for invalid values
assert!(ig.set_mu(1.3).is_ok());
assert!(ig.set_mu(0.0).is_err());
assert!(ig.set_mu(-1.0).is_err());
assert!(ig.set_mu(std::f64::NEG_INFINITY).is_err());
assert!(ig.set_mu(std::f64::INFINITY).is_err());
assert!(ig.set_mu(std::f64::NAN).is_err());Sourcepub fn set_mu_unchecked(&mut self, mu: f64)
pub fn set_mu_unchecked(&mut self, mu: f64)
Set the value of mu without input validation
Sourcepub fn lambda(&self) -> f64
pub fn lambda(&self) -> f64
Get lambda parameter
§Example
let ig = InvGaussian::new(2.0, 1.5).unwrap();
assert_eq!(ig.lambda(), 1.5);Sourcepub fn set_lambda(&mut self, lambda: f64) -> Result<(), InvGaussianError>
pub fn set_lambda(&mut self, lambda: f64) -> Result<(), InvGaussianError>
Set the value of lambda
§Example
let mut ig = InvGaussian::new(1.0, 2.0).unwrap();
assert_eq!(ig.lambda(), 2.0);
ig.set_lambda(2.3).unwrap();
assert_eq!(ig.lambda(), 2.3);Will error for invalid values
assert!(ig.set_lambda(2.3).is_ok());
assert!(ig.set_lambda(0.0).is_err());
assert!(ig.set_lambda(-1.0).is_err());
assert!(ig.set_lambda(std::f64::INFINITY).is_err());
assert!(ig.set_lambda(std::f64::NEG_INFINITY).is_err());
assert!(ig.set_lambda(std::f64::NAN).is_err());Sourcepub fn set_lambda_unchecked(&mut self, lambda: f64)
pub fn set_lambda_unchecked(&mut self, lambda: f64)
Set the value of lambda without input validation
Trait Implementations§
Source§impl Cdf<f32> for InvGaussian
impl Cdf<f32> for InvGaussian
Source§impl Cdf<f64> for InvGaussian
impl Cdf<f64> for InvGaussian
Source§impl Clone for InvGaussian
impl Clone for InvGaussian
Source§fn clone(&self) -> InvGaussian
fn clone(&self) -> InvGaussian
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ContinuousDistr<f32> for InvGaussian
impl ContinuousDistr<f32> for InvGaussian
Source§impl ContinuousDistr<f64> for InvGaussian
impl ContinuousDistr<f64> for InvGaussian
Source§impl Debug for InvGaussian
impl Debug for InvGaussian
Source§impl Display for InvGaussian
impl Display for InvGaussian
Source§impl HasSuffStat<f32> for InvGaussian
impl HasSuffStat<f32> for InvGaussian
type Stat = InvGaussianSuffStat
fn empty_suffstat(&self) -> <InvGaussian as HasSuffStat<f32>>::Stat
Source§fn ln_f_stat(&self, stat: &<InvGaussian as HasSuffStat<f32>>::Stat) -> f64
fn ln_f_stat(&self, stat: &<InvGaussian as HasSuffStat<f32>>::Stat) -> f64
Return the log likelihood for the data represented by the sufficient
statistic.
Source§impl HasSuffStat<f64> for InvGaussian
impl HasSuffStat<f64> for InvGaussian
type Stat = InvGaussianSuffStat
fn empty_suffstat(&self) -> <InvGaussian as HasSuffStat<f64>>::Stat
Source§fn ln_f_stat(&self, stat: &<InvGaussian as HasSuffStat<f64>>::Stat) -> f64
fn ln_f_stat(&self, stat: &<InvGaussian as HasSuffStat<f64>>::Stat) -> f64
Return the log likelihood for the data represented by the sufficient
statistic.
Source§impl Mean<f32> for InvGaussian
impl Mean<f32> for InvGaussian
Source§impl Mean<f64> for InvGaussian
impl Mean<f64> for InvGaussian
Source§impl Mode<f32> for InvGaussian
impl Mode<f32> for InvGaussian
Source§impl Mode<f64> for InvGaussian
impl Mode<f64> for InvGaussian
Source§impl PartialEq for InvGaussian
impl PartialEq for InvGaussian
Source§impl Rv<f32> for InvGaussian
impl Rv<f32> for InvGaussian
Source§impl Rv<f64> for InvGaussian
impl Rv<f64> for InvGaussian
Source§impl Support<f32> for InvGaussian
impl Support<f32> for InvGaussian
Source§impl Support<f64> for InvGaussian
impl Support<f64> for InvGaussian
Auto Trait Implementations§
impl !Freeze for InvGaussian
impl RefUnwindSafe for InvGaussian
impl Send for InvGaussian
impl Sync for InvGaussian
impl Unpin for InvGaussian
impl UnsafeUnpin for InvGaussian
impl UnwindSafe for InvGaussian
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<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>
Converts
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>
Converts
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<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.