Skip to content

Commit

Permalink
Fix cast and doc of fn Bernoulli::p
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Oct 17, 2024
1 parent d6a0b2b commit 78b5859
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/distr/bernoulli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ impl Bernoulli {

#[inline]
/// Returns the probability (`p`) of the distribution.
///
/// This value may differ slightly from the input due to loss of precision.
pub fn p(&self) -> f64 {
if self.p_int == ALWAYS_TRUE {
1.0
} else {
f64::from(self.p_int) / SCALE
(self.p_int as f64) / SCALE
}
}
}
Expand Down

0 comments on commit 78b5859

Please sign in to comment.