Skip to content

Commit

Permalink
fix: define no mode for gamma with shape<1
Browse files Browse the repository at this point in the history
  • Loading branch information
YeungOnion committed May 27, 2024
1 parent 2e3c453 commit d1fd362
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/distribution/gamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,16 @@ impl Mode<Option<f64>> for Gamma {
/// # Formula
///
/// ```text
/// (α - 1) / β
/// (α - 1) / β, where α≥1
/// ```
///
/// where `α` is the shape and `β` is the rate
fn mode(&self) -> Option<f64> {
Some((self.shape - 1.0) / self.rate)
if self.shape < 1.0 {
None
} else {
Some((self.shape - 1.0) / self.rate)
}
}
}

Expand Down

0 comments on commit d1fd362

Please sign in to comment.