pub struct Poisson<F>(/* private fields */)
where
F: Float + FloatConst,
Standard: Distribution<F>;
Expand description
The Poisson distribution Poisson(λ)
.
The Poisson distribution is a discrete probability distribution with
rate parameter λ
(lambda
). It models the number of events occurring in a fixed
interval of time or space.
This distribution has density function:
f(k) = λ^k * exp(-λ) / k!
for k >= 0
.
§Plot
The following plot shows the Poisson distribution with various values of λ
.
Note how the expected number of events increases with λ
.
§Example
use rand_distr::{Poisson, Distribution};
let poi = Poisson::new(2.0).unwrap();
let v: f64 = poi.sample(&mut rand::rng());
println!("{} is from a Poisson(2) distribution", v);
Implementations§
source§impl<F> Poisson<F>
impl<F> Poisson<F>
sourcepub const MAX_LAMBDA: f64 = 1.844E+19f64
pub const MAX_LAMBDA: f64 = 1.844E+19f64
The maximum supported value of lambda
This value was selected such that
MAX_LAMBDA + 1e6 * sqrt(MAX_LAMBDA) < 2^64 - 1
,
thus ensuring that the probability of sampling a value larger than
u64::MAX
is less than 1e-1000.
Applying this limit also solves #1312.
Trait Implementations§
source§impl<'de, F> Deserialize<'de> for Poisson<F>
impl<'de, F> Deserialize<'de> for Poisson<F>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<F> Distribution<F> for Poisson<F>
impl<F> Distribution<F> for Poisson<F>
source§impl Distribution<u64> for Poisson<f64>
impl Distribution<u64> for Poisson<f64>
impl<F> Copy for Poisson<F>
impl<F> StructuralPartialEq for Poisson<F>
Auto Trait Implementations§
impl<F> Freeze for Poisson<F>where
F: Freeze,
impl<F> RefUnwindSafe for Poisson<F>where
F: RefUnwindSafe,
impl<F> Send for Poisson<F>where
F: Send,
impl<F> Sync for Poisson<F>where
F: Sync,
impl<F> Unpin for Poisson<F>where
F: Unpin,
impl<F> UnwindSafe for Poisson<F>where
F: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)