Struct rv::dist::Gamma [−][src]
pub struct Gamma { /* fields omitted */ }
Gamma distribution G(α, β) over x in (0, ∞).
NOTE: The gamma distribution is parameterized in terms of shape, α, and rate, β.
β^α
f(x|α, β) = ---- x^(α-1) e^(-βx)
Γ(α)
Implementations
impl Gamma
[src]
impl Gamma
[src]pub fn new(shape: f64, rate: f64) -> Result<Self, GammaError>
[src]
Create a new Gamma
distribution with shape (α) and rate (β).
pub fn new_unchecked(shape: f64, rate: f64) -> Self
[src]
Creates a new Gamma without checking whether the parameters are valid.
pub fn shape(&self) -> f64
[src]
Get the shape parameter
Example
let gam = Gamma::new(2.0, 1.0).unwrap(); assert_eq!(gam.shape(), 2.0);
pub fn set_shape(&mut self, shape: f64) -> Result<(), GammaError>
[src]
Set the shape parameter
Example
let mut gam = Gamma::new(2.0, 1.0).unwrap(); assert_eq!(gam.shape(), 2.0); gam.set_shape(1.1).unwrap(); assert_eq!(gam.shape(), 1.1);
Will error for invalid values
assert!(gam.set_shape(1.1).is_ok()); assert!(gam.set_shape(0.0).is_err()); assert!(gam.set_shape(-1.0).is_err()); assert!(gam.set_shape(std::f64::INFINITY).is_err()); assert!(gam.set_shape(std::f64::NEG_INFINITY).is_err()); assert!(gam.set_shape(std::f64::NAN).is_err());
pub fn set_shape_unchecked(&mut self, shape: f64)
[src]
Set the shape parameter without input validation
pub fn rate(&self) -> f64
[src]
Get the rate parameter
Example
let gam = Gamma::new(2.0, 1.0).unwrap(); assert_eq!(gam.rate(), 1.0);
pub fn set_rate(&mut self, rate: f64) -> Result<(), GammaError>
[src]
Set the rate parameter
Example
let mut gam = Gamma::new(2.0, 1.0).unwrap(); assert_eq!(gam.rate(), 1.0); gam.set_rate(1.1).unwrap(); assert_eq!(gam.rate(), 1.1);
Will error for invalid values
assert!(gam.set_rate(1.1).is_ok()); assert!(gam.set_rate(0.0).is_err()); assert!(gam.set_rate(-1.0).is_err()); assert!(gam.set_rate(std::f64::INFINITY).is_err()); assert!(gam.set_rate(std::f64::NEG_INFINITY).is_err()); assert!(gam.set_rate(std::f64::NAN).is_err());
pub fn set_rate_unchecked(&mut self, rate: f64)
[src]
Set the rate parameter without input validation
Trait Implementations
impl Clone for Gamma
[src]
impl Clone for Gamma
[src]fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl ConjugatePrior<u16, Poisson> for Gamma
[src]
impl ConjugatePrior<u16, Poisson> for Gamma
[src]type Posterior = Self
Type of the posterior distribution
type LnMCache = f64
Type of the ln_m
cache
type LnPpCache = (f64, f64, f64)
Type of the ln_pp
cache
fn posterior(&self, x: &DataOrSuffStat<'_, u16, Poisson>) -> Self
[src]
fn ln_m_cache(&self) -> Self::LnMCache
[src]
fn ln_m_with_cache(
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, u16, Poisson>
) -> f64
[src]
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, u16, Poisson>
) -> f64
fn ln_pp_cache(&self, x: &DataOrSuffStat<'_, u16, Poisson>) -> Self::LnPpCache
[src]
fn ln_pp_with_cache(&self, cache: &Self::LnPpCache, y: &u16) -> 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<u32, Poisson> for Gamma
[src]
impl ConjugatePrior<u32, Poisson> for Gamma
[src]type Posterior = Self
Type of the posterior distribution
type LnMCache = f64
Type of the ln_m
cache
type LnPpCache = (f64, f64, f64)
Type of the ln_pp
cache
fn posterior(&self, x: &DataOrSuffStat<'_, u32, Poisson>) -> Self
[src]
fn ln_m_cache(&self) -> Self::LnMCache
[src]
fn ln_m_with_cache(
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, u32, Poisson>
) -> f64
[src]
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, u32, Poisson>
) -> f64
fn ln_pp_cache(&self, x: &DataOrSuffStat<'_, u32, Poisson>) -> Self::LnPpCache
[src]
fn ln_pp_with_cache(&self, cache: &Self::LnPpCache, y: &u32) -> 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<u8, Poisson> for Gamma
[src]
impl ConjugatePrior<u8, Poisson> for Gamma
[src]type Posterior = Self
Type of the posterior distribution
type LnMCache = f64
Type of the ln_m
cache
type LnPpCache = (f64, f64, f64)
Type of the ln_pp
cache
fn posterior(&self, x: &DataOrSuffStat<'_, u8, Poisson>) -> Self
[src]
fn ln_m_cache(&self) -> Self::LnMCache
[src]
fn ln_m_with_cache(
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, u8, Poisson>
) -> f64
[src]
&self,
cache: &Self::LnMCache,
x: &DataOrSuffStat<'_, u8, Poisson>
) -> f64
fn ln_pp_cache(&self, x: &DataOrSuffStat<'_, u8, Poisson>) -> Self::LnPpCache
[src]
fn ln_pp_with_cache(&self, cache: &Self::LnPpCache, y: &u8) -> 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<Poisson> for Gamma
[src]
impl ContinuousDistr<Poisson> for Gamma
[src]impl ContinuousDistr<f32> for Gamma
[src]
impl ContinuousDistr<f32> for Gamma
[src]impl ContinuousDistr<f64> for Gamma
[src]
impl ContinuousDistr<f64> for Gamma
[src]Auto Trait Implementations
impl RefUnwindSafe for Gamma
impl RefUnwindSafe for Gamma
impl UnwindSafe for Gamma
impl UnwindSafe for Gamma
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>,