diff --git a/src/distributions.rs b/src/distributions.rs index a948fea..eb20966 100644 --- a/src/distributions.rs +++ b/src/distributions.rs @@ -86,7 +86,7 @@ impl DiscreteDistribution { /// Creates a new Distribution from a given list of proabilities pub fn from_list(list: &Vec) -> Self { - if !is_close(list.into_iter().sum::(), 1.0, None) + if !is_close(list.into_iter().sum::(), 1.0) || !list.into_iter().all(|p| 0.0 <= *p && *p <= 1.0) { return Self { diff --git a/src/lib.rs b/src/lib.rs index 05a744e..9dfffe8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,8 +69,8 @@ impl FromStr for Algorithm { } /// Are two f64 close enough to be considered the same -pub fn is_close(a: f64, b: f64, tol: Option) -> bool { - (b - a).abs() < tol.unwrap_or(1e-09) +pub fn is_close(a: f64, b: f64) -> bool { + (b - a).abs() < 1e-09 } /// Get Factorial of Number