# [−][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

`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

`(λ^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 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 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 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

### `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 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 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 Mode<u64> for Poisson`[src]

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

Returns the mode of the poisson distribution

# Formula

`floor(λ)`

where `λ` is the rate

### `impl Clone for Poisson`[src]

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

Performs copy-assignment from `source`. Read more

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

## Blanket Implementations

### `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.