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

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));

Methods

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

This example is not tested
1 - P(x + 1, λ)

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

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

This example is not tested
(λ^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

This example is not tested
ln((λ^k * e^(-λ)) / x!)

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

This example is not tested
0

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

This example is not tested
2^63 - 1

impl Mean<f64> for Poisson[src]

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

Returns the mean of the poisson distribution

Formula

This example is not tested
λ

where λ is the rate

impl Variance<f64> for Poisson[src]

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

Returns the variance of the poisson distribution

Formula

This example is not tested
λ

where λ is the rate

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

Returns the standard deviation of the poisson distribution

Formula

This example is not tested
sqrt(λ)

where λ is the rate

impl Entropy<f64> for Poisson[src]

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

Returns the entropy of the poisson distribution

Formula

This example is not tested
(1 / 2) * ln(2πeλ) - 1 / (12λ) - 1 / (24λ^2) - 19 / (360λ^3)

where λ is the rate

impl Skewness<f64> for Poisson[src]

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

Returns the skewness of the poisson distribution

Formula

This example is not tested
λ^(-1/2)

where λ is the rate

impl Median<f64> for Poisson[src]

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

Returns the median of the poisson distribution

Formula

This example is not tested
floor(λ + 1 / 3 - 0.02 / λ)

where λ is the rate

impl Mode<u64> for Poisson[src]

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

Returns the mode of the poisson distribution

Formula

This example is not tested
floor(λ)

where λ is the rate

impl Copy for Poisson[src]

impl Clone for Poisson[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<Poisson> for Poisson[src]

impl Debug for Poisson[src]

impl Distribution<f64> for Poisson[src]

fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
    R: Rng
[src]

Create an iterator that generates random values of T, using rng as the source of randomness. Read more

Auto Trait Implementations

impl Send for Poisson

impl Sync for Poisson

Blanket Implementations

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

impl<T> From<T> for 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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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