-
-
Notifications
You must be signed in to change notification settings - Fork 473
Description
Summary
As a discrete probability distribution, the intuitive return type for Poisson random variates would seemingly be an integer type covering the distribution's support. This output strategy is already employed by other discrete probability distributions in rand_distr, like the "Bernoulli-related" Binomial distribution, Geometric distribution, and Hypergeometric distribution.
Details
The Poisson distribution implementation would need to be revised, to return a u64 (if following the Binomial, Geometric, and Hypergeometric precedent), instead of the current Float return type - a breaking API change. In addition to the API change, the internal implementation/calculations would need some revisions.
Motivation
What is the motivation for this change?
Making this change could make the crate more intuitive and dependent programs cleaner. Fundamentally, Poisson random variates are unsigned integers, so representing them as signed floats seems unintuitive. To me, this seems like an API made to match an internal implementation, rather than an API to match real-world intuition.
Alternatives
The Poisson random variates can be either f64 or f32, but some basic type casting logic is nevertheless fairly straightforward. Any of the possible type casts require some thought around truncation, etc., but I don't see any major issues with the cast strategy.
Notes
Through some digging, I see that a u64 return type was the initial implementation #96, yet this was later modified c03e2c8. Are we calling this a "done deal" and settling on the float return type? If there's shared interest in revisiting this, I could take a stab at the PR.