Skip to content

Commit

Permalink
chore: simple lints
Browse files Browse the repository at this point in the history
also derives Eq for DiscreteUniform distribution
  • Loading branch information
YeungOnion committed Dec 2, 2024
1 parent 12b0119 commit e7a995e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/distribution/discrete_uniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::statistics::*;
/// assert_eq!(n.mean().unwrap(), 2.5);
/// assert_eq!(n.pmf(3), 1.0 / 6.0);
/// ```
#[derive(Copy, Clone, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct DiscreteUniform {
min: i64,
max: i64,
Expand Down
10 changes: 3 additions & 7 deletions src/distribution/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ pub fn integral_bisection_search<K: Num + Clone, T: Num + PartialOrd>(
loop {
let mid = (lb.clone() + ub.clone()) / two.clone();
if !(f(&lb)..=f(&ub)).contains(&f(&mid)) {
// if f found not monotone on the interval
return None;
return None; // f found not monotone on interval
} else if f(&lb) == z {
return Some(lb);
} else if f(&ub) == z {
return Some(ub);
} else if (lb.clone() + K::one()) == ub {
// no more elements to search
return Some(ub);
} else if f(&ub) == z || (lb.clone() + K::one()) == ub {
return Some(ub); // found or no more integers between
} else if f(&mid) >= z {
ub = mid;
} else {
Expand Down
1 change: 0 additions & 1 deletion src/distribution/multivariate_normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ where
/// where `L` is the Cholesky decomposition of the covariance matrix,
/// `Z` is a vector of normally distributed random variables, and
/// `μ` is the mean vector

fn sample<R: ::rand::Rng + ?Sized>(&self, rng: &mut R) -> OVector<f64, D> {
let d = crate::distribution::Normal::new(0., 1.).unwrap();
let z = OVector::from_distribution_generic(self.mu.shape_generic().0, Const::<1>, &d, rng);
Expand Down

0 comments on commit e7a995e

Please sign in to comment.