Skip to content

Commit

Permalink
fix log_normal test
Browse files Browse the repository at this point in the history
  • Loading branch information
JamboChen committed Oct 9, 2024
1 parent d4f9226 commit b347cb0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rand_distr/tests/cdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,20 @@ fn log_normal() {
} else if x.is_infinite() {
1.0
} else {
0.5 * (mean - x.ln() / (std_dev * f64::consts::SQRT_2)).erfc()
0.5 * ((mean - x.ln()) / (std_dev * f64::consts::SQRT_2)).erfc()
}
}

let parameters = [
(0.0, 1.0),
(0.0, 0.1),
(0.5, 0.7),
(1.0, 10.0),
(1.0, 100.0),
(-1.0, 0.00001),
(-1.0, 0.0000001),
];

println!("{}", cdf(5.0, 2.0, 1.5));

for (seed, (mean, std_dev)) in parameters.into_iter().enumerate() {
let dist = rand_distr::LogNormal::new(mean, std_dev).unwrap();
test_continuous(seed as u64, dist, |x| cdf(x, mean, std_dev));
Expand Down

0 comments on commit b347cb0

Please sign in to comment.