Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/distribution/geometric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@ impl DiscreteCDF<u64, f64> for Geometric {
}
let k = (-x).ln_1p() / (-self.p).ln_1p();
if !k.is_finite() {
panic!("inverse_cdf: intermediate value overflowed f64; p ({}) is too small", self.p);
panic!(
"inverse_cdf: intermediate value overflowed f64; p ({}) is too small",
self.p
);
}
let k = k.ceil();
if k >= u64::MAX as f64 {
panic!("inverse_cdf: result exceeds u64::MAX; p ({}) is too small for x ({})", self.p, x);
panic!(
"inverse_cdf: result exceeds u64::MAX; p ({}) is too small for x ({})",
self.p, x
);
}
k as u64
}
Expand Down
Loading