pub struct InvGamma { /* private fields */ }Expand description
Inverse gamma distribution IG(α, β) over x in (0, ∞).
β^α
f(x|α, β) = ---- x^(-α-1) e^(-β/x)
Γ(α)Implementations§
Source§impl InvGamma
impl InvGamma
Sourcepub fn new(shape: f64, scale: f64) -> Result<Self, InvGammaError>
pub fn new(shape: f64, scale: f64) -> Result<Self, InvGammaError>
Create a new Gamma distribution with shape (α) and rate (β).
§Arguments
- shape: shape parameter, α
- scale scale parameter, β
Sourcepub fn new_unchecked(shape: f64, scale: f64) -> Self
pub fn new_unchecked(shape: f64, scale: f64) -> Self
Creates a new InvGamma without checking whether the parameters are
valid.
Sourcepub fn shape(&self) -> f64
pub fn shape(&self) -> f64
Get the shape parameter
§Example
let ig = InvGamma::new(1.0, 2.0).unwrap();
assert_eq!(ig.shape(), 1.0);Sourcepub fn set_shape(&mut self, shape: f64) -> Result<(), InvGammaError>
pub fn set_shape(&mut self, shape: f64) -> Result<(), InvGammaError>
Set the shape parameter
§Example
let mut ig = InvGamma::new(2.0, 1.0).unwrap();
assert_eq!(ig.shape(), 2.0);
ig.set_shape(1.1).unwrap();
assert_eq!(ig.shape(), 1.1);Will error for invalid values
assert!(ig.set_shape(1.1).is_ok());
assert!(ig.set_shape(0.0).is_err());
assert!(ig.set_shape(-1.0).is_err());
assert!(ig.set_shape(f64::INFINITY).is_err());
assert!(ig.set_shape(f64::NEG_INFINITY).is_err());
assert!(ig.set_shape(f64::NAN).is_err());Sourcepub fn set_shape_unchecked(&mut self, shape: f64)
pub fn set_shape_unchecked(&mut self, shape: f64)
Set the shape parameter without input validation
Sourcepub fn scale(&self) -> f64
pub fn scale(&self) -> f64
Get the scale parameter
§Example
let ig = InvGamma::new(1.0, 2.0).unwrap();
assert_eq!(ig.scale(), 2.0);Sourcepub fn set_scale(&mut self, scale: f64) -> Result<(), InvGammaError>
pub fn set_scale(&mut self, scale: f64) -> Result<(), InvGammaError>
Set the scale parameter
§Example
let mut ig = InvGamma::new(2.0, 1.0).unwrap();
assert_eq!(ig.scale(), 1.0);
ig.set_scale(1.1).unwrap();
assert_eq!(ig.scale(), 1.1);Will error for invalid values
assert!(ig.set_scale(1.1).is_ok());
assert!(ig.set_scale(0.0).is_err());
assert!(ig.set_scale(-1.0).is_err());
assert!(ig.set_scale(f64::INFINITY).is_err());
assert!(ig.set_scale(f64::NEG_INFINITY).is_err());
assert!(ig.set_scale(f64::NAN).is_err());Sourcepub fn set_scale_unchecked(&mut self, scale: f64)
pub fn set_scale_unchecked(&mut self, scale: f64)
Set the scale parameter without input validation
Trait Implementations§
Source§impl ContinuousDistr<f32> for InvGamma
impl ContinuousDistr<f32> for InvGamma
Source§impl ContinuousDistr<f64> for InvGamma
impl ContinuousDistr<f64> for InvGamma
Source§impl<'de> Deserialize<'de> for InvGamma
impl<'de> Deserialize<'de> for InvGamma
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 HasDensity<f32> for InvGamma
impl HasDensity<f32> for InvGamma
Source§impl HasDensity<f64> for InvGamma
impl HasDensity<f64> for InvGamma
Source§impl HasSuffStat<f32> for InvGamma
impl HasSuffStat<f32> for InvGamma
Source§impl HasSuffStat<f64> for InvGamma
impl HasSuffStat<f64> for InvGamma
Source§impl Parameterized for InvGamma
impl Parameterized for InvGamma
type Parameters = InvGammaParameters
fn emit_params(&self) -> Self::Parameters
fn from_params(params: Self::Parameters) -> Self
fn map_params(&self, f: impl Fn(Self::Parameters) -> Self::Parameters) -> Self
Source§impl Sampleable<f32> for InvGamma
impl Sampleable<f32> for InvGamma
Source§impl Sampleable<f64> for InvGamma
impl Sampleable<f64> for InvGamma
impl StructuralPartialEq for InvGamma
Auto Trait Implementations§
impl Freeze for InvGamma
impl RefUnwindSafe for InvGamma
impl Send for InvGamma
impl Sync for InvGamma
impl Unpin for InvGamma
impl UnwindSafe for InvGamma
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.