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
source§impl PartialEq for InvGamma
impl PartialEq for InvGamma
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§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.