use statrs::distribution::{Discrete, DiscreteCDF, NegativeBinomial};
fn main() {
for (r, p) in [(1.0, 1.0), (2.5, 1.0), (1.0, 0.999)] {
let nb = NegativeBinomial::new(r, p).unwrap();
println!("r = {r}, p = {p}: pmf(0) = {:?}, cdf(0) = {:?}", nb.pmf(0), nb.cdf(0));
}
}
Output:
r = 1, p = 1: pmf(0) = NaN, cdf(0) = 1.0
r = 2.5, p = 1: pmf(0) = NaN, cdf(0) = 1.0
r = 1, p = 0.999: pmf(0) = 0.9990000000000004, cdf(0) = 0.999
With p = 1 every trial succeeds, so all the mass is at 0 and pmf(0) should be 1 — which is what cdf(0) reports. new accepts p = 1, and p = 0.999 works.
Tested on statrs 0.19.1 and current main (50fcf4d).
(This was another bug found using hegel.)
Output:
With
p = 1every trial succeeds, so all the mass is at 0 andpmf(0)should be 1 — which is whatcdf(0)reports.newacceptsp = 1, andp = 0.999works.Tested on statrs 0.19.1 and current main (50fcf4d).
(This was another bug found using hegel.)