Struct statrs::distribution::Poisson[][src]

pub struct Poisson { /* fields omitted */ }

Implements the Poisson distribution

Examples

use statrs::distribution::{Poisson, Discrete};
use statrs::statistics::Mean;
use statrs::prec;

let n = Poisson::new(1.0).unwrap();
assert_eq!(n.mean(), 1.0);
assert!(prec::almost_eq(n.pmf(1), 0.367879441171442, 1e-15));

Implementations

impl Poisson[src]

pub fn new(lambda: f64) -> Result<Poisson>[src]

Constructs a new poisson distribution with a rate (λ) of lambda

Errors

Returns an error if lambda is NaN or lambda <= 0.0

Examples

use statrs::distribution::Poisson;

let mut result = Poisson::new(1.0);
assert!(result.is_ok());

result = Poisson::new(0.0);
assert!(result.is_err());

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

Returns the rate (λ) of the poisson distribution

Examples

use statrs::distribution::Poisson;

let n = Poisson::new(1.0).unwrap();
assert_eq!(n.lambda(), 1.0);

Trait Implementations

impl Clone for Poisson[src]

impl Copy for Poisson[src]

impl Debug for Poisson[src]

impl Discrete<u64, f64> for Poisson[src]

fn pmf(&self, x: u64) -> f64[src]

Calculates the probability mass function for the poisson distribution at x

Formula

(λ^k * e^(-λ)) / x!

where λ is the rate

fn ln_pmf(&self, x: u64) -> f64[src]

Calculates the log probability mass function for the poisson distribution at x

Formula

ln((λ^k * e^(-λ)) / x!)

where λ is the rate

impl Distribution<f64> for Poisson[src]

impl Entropy<f64> for Poisson[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the poisson distribution

Formula

(1 / 2) * ln(2πeλ) - 1 / (12λ) - 1 / (24λ^2) - 19 / (360λ^3)

where λ is the rate

impl Max<u64> for Poisson[src]

fn max(&self) -> u64[src]

Returns the maximum value in the domain of the poisson distribution representable by a 64-bit integer

Formula

2^63 - 1

impl Mean<f64> for Poisson[src]

fn mean(&self) -> f64[src]

Returns the mean of the poisson distribution

Formula

λ

where λ is the rate

impl Median<f64> for Poisson[src]

fn median(&self) -> f64[src]

Returns the median of the poisson distribution

Formula

floor(λ + 1 / 3 - 0.02 / λ)

where λ is the rate

impl Min<u64> for Poisson[src]

fn min(&self) -> u64[src]

Returns the minimum value in the domain of the poisson distribution representable by a 64-bit integer

Formula

0

impl Mode<u64> for Poisson[src]

fn mode(&self) -> u64[src]

Returns the mode of the poisson distribution

Formula

floor(λ)

where λ is the rate

impl PartialEq<Poisson> for Poisson[src]

impl Skewness<f64> for Poisson[src]

fn skewness(&self) -> f64[src]

Returns the skewness of the poisson distribution

Formula

λ^(-1/2)

where λ is the rate

impl StructuralPartialEq for Poisson[src]

impl Univariate<u64, f64> for Poisson[src]

fn cdf(&self, x: f64) -> f64[src]

Calculates the cumulative distribution function for the poisson distribution at x

Formula

1 - P(x + 1, λ)

where λ is the rate and P is the lower regularized gamma function

impl Variance<f64> for Poisson[src]

fn variance(&self) -> f64[src]

Returns the variance of the poisson distribution

Formula

λ

where λ is the rate

fn std_dev(&self) -> f64[src]

Returns the standard deviation of the poisson distribution

Formula

sqrt(λ)

where λ is the rate

Auto Trait Implementations

impl RefUnwindSafe for Poisson

impl Send for Poisson

impl Sync for Poisson

impl Unpin for Poisson

impl UnwindSafe for Poisson

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

type Owned = T

The resulting type after obtaining ownership.

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>, 
[src]