Skip to content

Commit

Permalink
fix: return None for Gamma::mode when α < 1
Browse files Browse the repository at this point in the history
  • Loading branch information
YeungOnion committed Apr 16, 2024
1 parent ecc39cc commit 298c6fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/distribution/gamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,15 @@ impl Mode<Option<f64>> for Gamma {
/// # Formula
///
/// ```text
/// max{(α - 1) / β, 0}
/// (α - 1) / β, where α > 1
/// ```
///
/// where `α` is the shape and `β` is the rate
fn mode(&self) -> Option<f64> {
if self.shape > 1.0 {
if self.shape >= 1.0 {
Some((self.shape - 1.0) / self.rate)
} else {
Some(0.0)
None
}
}
}
Expand Down

0 comments on commit 298c6fd

Please sign in to comment.