Skip to content

Commit 81c4a48

Browse files
author
Goose
committed
add comments
1 parent a6abcc1 commit 81c4a48

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/distribution/geometric.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,11 @@ impl DiscreteCDF<u64, f64> for Geometric {
172172
// = ceil((-x).ln_1p()/(-self.p).ln_1p())
173173
// = ((-x).ln_1p()/(-self.p).ln_1p()).ceil()
174174
if x <= self.cdf(self.min()) {
175+
// if p = 1 this branch will always be taken
176+
// no matter the value of x
175177
return self.min();
176178
} else if x == <f64>::one() {
179+
// note that if p = 1 & x = 1 the above branch is taken
177180
return self.max();
178181
} else if !(<f64>::zero()..=<f64>::one()).contains(&x) {
179182
std::panic!("p must be on [0, 1]")

0 commit comments

Comments
 (0)