Skip to content

Commit ed1b718

Browse files
committed
Document fn Geometric::new edge case
1 parent a45c124 commit ed1b718

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/geometric.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ impl fmt::Display for Error {
6767
impl std::error::Error for Error {}
6868

6969
impl Geometric {
70-
/// Construct a new `Geometric` with the given shape parameter `p`
71-
/// (probability of success on each trial).
70+
/// Construct a new `Geometric` distribution
71+
///
72+
/// The shape parameter `p` is the probability of success on each trial.
73+
///
74+
/// ### Edge cases
75+
///
76+
/// If `p == 0.0` or `1.0 - p` rounds to `1.0` then sampling returns
77+
/// `u64::MAX`.
7278
pub fn new(p: f64) -> Result<Self, Error> {
7379
let mut pi = 1.0 - p;
7480
if !p.is_finite() || !(0.0..=1.0).contains(&p) {

0 commit comments

Comments
 (0)