We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a6abcc1 commit 81c4a48Copy full SHA for 81c4a48
src/distribution/geometric.rs
@@ -172,8 +172,11 @@ impl DiscreteCDF<u64, f64> for Geometric {
172
// = ceil((-x).ln_1p()/(-self.p).ln_1p())
173
// = ((-x).ln_1p()/(-self.p).ln_1p()).ceil()
174
if x <= self.cdf(self.min()) {
175
+ // if p = 1 this branch will always be taken
176
+ // no matter the value of x
177
return self.min();
178
} else if x == <f64>::one() {
179
+ // note that if p = 1 & x = 1 the above branch is taken
180
return self.max();
181
} else if !(<f64>::zero()..=<f64>::one()).contains(&x) {
182
std::panic!("p must be on [0, 1]")
0 commit comments