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

Methods

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

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 Debug for Poisson
[src]

Formats the value using the given formatter.

impl Copy for Poisson
[src]

impl Clone for Poisson
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Poisson
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Sample<f64> for Poisson
[src]

Generate a random sample from a poisson distribution using r as the source of randomness. Refer here for implementation details

impl IndependentSample<f64> for Poisson
[src]

Generate a random independent sample from a poisson distribution using r as the source of randomness. Refer here for implementation details

impl Distribution<f64> for Poisson
[src]

Generate a random sample from a poisson distribution using r as the source of randomness. The implementation is based on Knuth's method if lambda < 30.0 or Rejection method PA by A. C. Atkinson from the Journal of the Royal Statistical Society Series C (Applied Statistics) Vol. 28 No. 1. (1979) pp. 29 - 35

Examples

use rand::StdRng;
use statrs::distribution::{Poisson, Distribution};

let mut r = rand::StdRng::new().unwrap();
let n = Poisson::new(1.0).unwrap();
print!("{}", n.sample::<StdRng>(&mut r));

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

Calculates the cumulative distribution function for the poisson distribution at x

Panics

If x < 0.0

Formula

1 - P(x + 1, λ)

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

impl Min<i64> for Poisson
[src]

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

Formula

0

impl Max<i64> for Poisson
[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]

Returns the mean of the poisson distribution

Formula

λ

where λ is the rate

impl Variance<f64> for Poisson
[src]

Returns the variance of the poisson distribution

Formula

λ

where λ is the rate

Returns the standard deviation of the poisson distribution

Formula

sqrt(λ)

where λ is the rate

impl Entropy<f64> for Poisson
[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 Skewness<f64> for Poisson
[src]

Returns the skewness of the poisson distribution

Formula

λ^(-1/2)

where λ is the rate

impl Median<f64> for Poisson
[src]

Returns the median of the poisson distribution

Formula

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

where λ is the rate

impl Mode<i64> for Poisson
[src]

Returns the mode of the poisson distribution

Formula

floor(λ)

where λ is the rate

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

Calculates the probability mass function for the poisson distribution at x

Panics

Panics if x < 0.0

Formula

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

where λ is the rate

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

Panics

Panics if x < 0.0

Formula

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

where λ is the rate