Skip to content

Commit

Permalink
test(docs): update Multinomial doc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YeungOnion committed Aug 3, 2024
1 parent 2d2e4f5 commit cd16782
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/distribution/multinomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use rand::Rng;
/// ```
/// use statrs::distribution::Multinomial;
/// use statrs::statistics::MeanN;
/// use nalgebra::DVector;
/// use nalgebra::vector;
///
/// let n = Multinomial::new(&[0.3, 0.7], 5).unwrap();
/// assert_eq!(n.mean().unwrap(), DVector::from_vec(vec![1.5, 3.5]));
/// let n = Multinomial::new_from_nalgebra(vector![0.3, 0.7], 5).unwrap();
/// assert_eq!(n.mean().unwrap(), (vector![1.5, 3.5]));
/// ```
#[derive(Debug, Clone, PartialEq)]
pub struct Multinomial<D>
Expand Down Expand Up @@ -87,9 +87,10 @@ where
///
/// ```
/// use statrs::distribution::Multinomial;
/// use nalgebra::dvector;
///
/// let n = Multinomial::new(&[0.0, 1.0, 2.0], 3).unwrap();
/// assert_eq!(n.p(), [0.0, 1.0, 2.0]);
/// let n = Multinomial::new(vec![0.0, 1.0, 2.0], 3).unwrap();
/// assert_eq!(*n.p(), dvector![0.0, 1.0/3.0, 2.0/3.0]);
/// ```
pub fn p(&self) -> &OVector<f64, D> {
&self.p
Expand All @@ -103,7 +104,7 @@ where
/// ```
/// use statrs::distribution::Multinomial;
///
/// let n = Multinomial::new(&[0.0, 1.0, 2.0], 3).unwrap();
/// let n = Multinomial::new(vec![0.0, 1.0, 2.0], 3).unwrap();
/// assert_eq!(n.n(), 3);
/// ```
pub fn n(&self) -> u64 {
Expand Down Expand Up @@ -300,6 +301,7 @@ mod tests {
distribution::{Discrete, DiscreteCDF, Multinomial},
statistics::{Max, MeanN, Min, Mode, VarianceN},
};
use approx::UlpsEq;
use nalgebra::{
dmatrix, dvector, matrix, vector, Const, DimMin, Dyn, Matrix, OMatrix, OVector,
VecStorage,
Expand Down

0 comments on commit cd16782

Please sign in to comment.