pub struct Poisson { /* private fields */ }Expand description
A discrete distribution for modeling the number of events occurring in a fixed interval.
Returns u64 for natural counting arithmetic.
Mathematical Properties:
- Support: {0, 1, 2, 3, …}
- PMF: P(X = k) = (λ^k × e^(-λ)) / k!
- Mean: λ
- Variance: λ
- Memoryless: Past events don’t affect future rates
Example:
// Model event counts
let events = sample(addr!("events"), Poisson::new(3.0).unwrap())
.bind(|count| {
let status = match count {
0 => "No events",
1 => "Single event",
n if n > 10 => "High activity",
_ => "Normal activity"
};
pure(status.to_string())
});
// Hierarchical model with Gamma prior
let hierarchical = sample(addr!("rate"), Gamma::new(2.0, 1.0).unwrap())
.bind(|lambda| sample(addr!("count"), Poisson::new(lambda).unwrap()));
// Observe count data
let observed = observe(addr!("observed_count"), Poisson::new(4.0).unwrap(), 7u64);Implementations§
Trait Implementations§
Source§impl Distribution<u64> for Poisson
impl Distribution<u64> for Poisson
Source§fn sample(&self, rng: &mut dyn RngCore) -> u64
fn sample(&self, rng: &mut dyn RngCore) -> u64
Generate a random sample (with its natural type),
T, from the distribution, using the provided random number generator, rng. Read moreimpl Copy for Poisson
Auto Trait Implementations§
impl Freeze for Poisson
impl RefUnwindSafe for Poisson
impl Send for Poisson
impl Sync for Poisson
impl Unpin for Poisson
impl UnwindSafe for Poisson
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