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]

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 Cdf<f32> for Gamma[src]

impl Cdf<f64> for Gamma[src]

impl Clone 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

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

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

impl ContinuousDistr<Poisson> for Gamma[src]

impl ContinuousDistr<f32> for Gamma[src]

impl ContinuousDistr<f64> for Gamma[src]

impl Debug for Gamma[src]

impl Default for Gamma[src]

impl Display for Gamma[src]

impl Entropy for Gamma[src]

impl Kurtosis for Gamma[src]

impl Mean<f32> for Gamma[src]

impl Mean<f64> for Gamma[src]

impl Mode<f32> for Gamma[src]

impl Mode<f64> for Gamma[src]

impl PartialEq<Gamma> for Gamma[src]

impl Rv<Poisson> for Gamma[src]

impl Rv<f32> for Gamma[src]

impl Rv<f64> for Gamma[src]

impl Skewness for Gamma[src]

impl Support<Poisson> for Gamma[src]

impl Support<f32> for Gamma[src]

impl Support<f64> for Gamma[src]

impl Variance<f64> for Gamma[src]

Auto Trait Implementations

impl RefUnwindSafe for Gamma

impl Send for Gamma

impl Sync for Gamma

impl Unpin for Gamma

impl UnwindSafe for Gamma

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,