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]
fn new(lambda: f64) -> Result<Poisson>
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());
fn lambda(&self) -> f64
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]
impl Copy for Poisson
[src]
impl Clone for Poisson
[src]
fn clone(&self) -> Poisson
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Poisson
[src]
fn eq(&self, __arg_0: &Poisson) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Poisson) -> bool
This method tests for !=
.
impl Sample<f64> for Poisson
[src]
fn sample<R: Rng>(&mut self, r: &mut R) -> f64
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]
fn ind_sample<R: Rng>(&self, r: &mut R) -> f64
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]
fn sample<R: Rng>(&self, r: &mut R) -> f64
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]
impl Min<i64> for Poisson
[src]
fn min(&self) -> i64
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]
fn max(&self) -> i64
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]
impl Variance<f64> for Poisson
[src]
impl Entropy<f64> for Poisson
[src]
fn entropy(&self) -> f64
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]
impl Median<f64> for Poisson
[src]
fn median(&self) -> f64
Returns the median of the poisson distribution
Formula
floor(λ + 1 / 3 - 0.02 / λ)
where λ
is the rate