Struct rv::dist::InvGaussian
source · 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<Self, InvGaussianError>
pub fn new(mu: f64, lambda: f64) -> Result<Self, InvGaussianError>
Create a new Inverse Gaussian distribution
§Arguments
- 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) -> Self
pub fn new_unchecked(mu: f64, lambda: f64) -> Self
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(f64::NEG_INFINITY).is_err());
assert!(ig.set_mu(f64::INFINITY).is_err());
assert!(ig.set_mu(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(f64::INFINITY).is_err());
assert!(ig.set_lambda(f64::NEG_INFINITY).is_err());
assert!(ig.set_lambda(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 copy 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<'de> Deserialize<'de> for InvGaussian
impl<'de> Deserialize<'de> for InvGaussian
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for InvGaussian
impl Display for InvGaussian
source§impl From<&InvGaussian> for String
impl From<&InvGaussian> for String
source§fn from(ig: &InvGaussian) -> String
fn from(ig: &InvGaussian) -> String
Converts to this type from the input type.
source§impl HasDensity<f32> for InvGaussian
impl HasDensity<f32> for InvGaussian
source§impl HasDensity<f64> for InvGaussian
impl HasDensity<f64> for InvGaussian
source§impl HasSuffStat<f32> for InvGaussian
impl HasSuffStat<f32> for InvGaussian
source§impl HasSuffStat<f64> for InvGaussian
impl HasSuffStat<f64> for InvGaussian
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 Parameterized for InvGaussian
impl Parameterized for InvGaussian
type Parameters = InvGaussianParameters
fn emit_params(&self) -> Self::Parameters
fn from_params(params: Self::Parameters) -> Self
source§impl PartialEq for InvGaussian
impl PartialEq for InvGaussian
source§fn eq(&self, other: &InvGaussian) -> bool
fn eq(&self, other: &InvGaussian) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Sampleable<f32> for InvGaussian
impl Sampleable<f32> for InvGaussian
source§impl Sampleable<f64> for InvGaussian
impl Sampleable<f64> for InvGaussian
source§impl Serialize for InvGaussian
impl Serialize 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 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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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.