[][src]Struct rv::dist::Skellam

pub struct Skellam { /* fields omitted */ }

Skellam distribution over x in {.., -2, -1, 0, 1, ... }.

Example

use rv::prelude::*;

// Create Skellam(μ_1=5.3, μ_2=2.5)
let skel = Skellam::new(5.3, 2.5).unwrap();

// Draw 100 samples
let mut rng = rand::thread_rng();
let xs: Vec<i32> = skel.sample(100, &mut rng);
assert_eq!(xs.len(), 100)

Implementations

impl Skellam[src]

pub fn new(mu_1: f64, mu_2: f64) -> Result<Self, SkellamError>[src]

Create a new Skellam distribution with given rates

pub fn new_unchecked(mu_1: f64, mu_2: f64) -> Self[src]

Creates a new Skellam without checking whether the parameters are valid.

pub fn mu_1(&self) -> f64[src]

Get the mu_1 parameter

Example

let skel = Skellam::new(2.0, 3.0).unwrap();
assert_eq!(skel.mu_1(), 2.0);

pub fn set_mu_1(&mut self, mu_1: f64) -> Result<(), SkellamError>[src]

Set the mu_1 (first rate) parameter

Example

use rv::dist::Skellam;
let mut skel = Skellam::new(2.0, 1.0).unwrap();
assert_eq!(skel.mu_1(), 2.0);

skel.set_mu_1(1.1).unwrap();
assert_eq!(skel.mu_1(), 1.1);

Will error for invalid values

assert!(skel.set_mu_1(1.1).is_ok());
assert!(skel.set_mu_1(0.0).is_err());
assert!(skel.set_mu_1(-1.0).is_err());
assert!(skel.set_mu_1(std::f64::INFINITY).is_err());
assert!(skel.set_mu_1(std::f64::NEG_INFINITY).is_err());
assert!(skel.set_mu_1(std::f64::NAN).is_err());

pub fn set_mu_1_unchecked(&mut self, mu_1: f64)[src]

Set the mu_1 (first rate) parameter without input validation

pub fn mu_2(&self) -> f64[src]

Get the mu_2 parameter

Example

let skel = Skellam::new(2.0, 3.0).unwrap();
assert_eq!(skel.mu_2(), 3.0);

pub fn set_mu_2(&mut self, mu_2: f64) -> Result<(), SkellamError>[src]

Set the mu_2 (second rate) parameter

Example

use rv::dist::Skellam;
let mut skel = Skellam::new(2.0, 1.0).unwrap();
assert_eq!(skel.mu_2(), 1.0);

skel.set_mu_2(1.1).unwrap();
assert_eq!(skel.mu_2(), 1.1);

Will error for invalid values

assert!(skel.set_mu_2(1.1).is_ok());
assert!(skel.set_mu_2(0.0).is_err());
assert!(skel.set_mu_2(-1.0).is_err());
assert!(skel.set_mu_2(std::f64::INFINITY).is_err());
assert!(skel.set_mu_2(std::f64::NEG_INFINITY).is_err());
assert!(skel.set_mu_2(std::f64::NAN).is_err());

pub fn set_mu_2_unchecked(&mut self, mu_2: f64)[src]

Set the mu_2 (first rate) parameter without input validation

pub fn set_cache_cap(&self, cap: usize)[src]

Set the cache size on the internal LRU for Bessel Iv calls.

Trait Implementations

impl Clone for Skellam[src]

impl Debug for Skellam[src]

impl DiscreteDistr<i16> for Skellam[src]

impl DiscreteDistr<i32> for Skellam[src]

impl DiscreteDistr<i8> for Skellam[src]

impl Display for Skellam[src]

impl<'_> From<&'_ Skellam> for String[src]

impl Kurtosis for Skellam[src]

impl Mean<f64> for Skellam[src]

impl PartialEq<Skellam> for Skellam[src]

impl Rv<i16> for Skellam[src]

impl Rv<i32> for Skellam[src]

impl Rv<i8> for Skellam[src]

impl Skewness for Skellam[src]

impl Support<i16> for Skellam[src]

impl Support<i32> for Skellam[src]

impl Support<i8> for Skellam[src]

impl Variance<f64> for Skellam[src]

Auto Trait Implementations

impl !RefUnwindSafe for Skellam

impl Send for Skellam

impl !Sync for Skellam

impl Unpin for Skellam

impl UnwindSafe for Skellam

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<Fx, X> DiscreteDistr<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: DiscreteDistr<X>, 
[src]

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

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

impl<Fx> Kurtosis for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Kurtosis
[src]

impl<Fx, X> Mean<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Mean<X>, 
[src]

impl<Fx, X> Rv<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Rv<X>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<Fx> Skewness for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Skewness
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<Fx, X> Support<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Support<X>, 
[src]

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>, 

impl<Fx, X> Variance<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Variance<X>, 
[src]