Skip to content

Commit

Permalink
test: cdf(inverse_cdf(p)) ~ p for `<Gamma as ContinuousCDF>::inverse_…
Browse files Browse the repository at this point in the history
…cdf`
  • Loading branch information
YeungOnion committed May 16, 2024
1 parent 902003e commit 9041a98
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/distribution/gamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,25 @@ mod tests {
test_case((1.0, 0.1), 0.0, |x| x.cdf(0.0));
}

#[test]
fn test_cdf_inverse_identity() {
let f = |p: f64| move |g: Gamma| g.cdf(g.inverse_cdf(p));
let params = [
(1.0, 0.1),
(1.0, 1.0),
(10.0, 10.0),
(10.0, 1.0),
(100.0, 200.0),
];

for param in params {
for n in -5..0 {
let p = 10.0f64.powi(n);
test_case(param, p, f(p));
}
}
}

#[test]
fn test_sf() {
let f = |arg: f64| move |x: Gamma| x.sf(arg);
Expand Down

0 comments on commit 9041a98

Please sign in to comment.