From bafd74da7002321c0378b6753204933b04d386b8 Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Sun, 3 Feb 2019 11:06:06 +0100 Subject: [PATCH] Fix doc-tests for variance. --- src/base/statistics.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 31f46d03..11cc9e1c 100644 --- a/src/base/statistics.rs +++ b/src/base/statistics.rs @@ -76,6 +76,9 @@ impl> Matrix { } /// The sum of all the rows of this matrix. + /// + /// Use `.row_variance_tr` if you need the result in a column vector instead. + /// /// # Example /// /// ``` @@ -138,11 +141,12 @@ impl> Matrix { /// # Example /// /// ``` + /// # #[macro_use] extern crate approx; /// # use nalgebra::Matrix2x3; /// /// let m = Matrix2x3::new(1.0, 2.0, 3.0, /// 4.0, 5.0, 6.0); - /// assert_eq!(m.variance(), 3.5); + /// assert_relative_eq!(m.variance(), 35.0 / 12.0, epsilon = 1.0e-8); /// ``` #[inline] pub fn variance(&self) -> N { @@ -156,6 +160,8 @@ impl> Matrix { } /// The variance of all the rows of this matrix. + /// + /// Use `.row_variance_tr` if you need the result in a column vector instead. /// # Example /// /// ``` @@ -163,7 +169,7 @@ impl> Matrix { /// /// let m = Matrix2x3::new(1.0, 2.0, 3.0, /// 4.0, 5.0, 6.0); - /// assert_eq!(m.row_variance(), RowVector3::new(4.5, 4.5, 4.5)); + /// assert_eq!(m.row_variance(), RowVector3::new(2.25, 2.25, 2.25)); /// ``` #[inline] pub fn row_variance(&self) -> RowVectorN @@ -180,7 +186,7 @@ impl> Matrix { /// /// let m = Matrix2x3::new(1.0, 2.0, 3.0, /// 4.0, 5.0, 6.0); - /// assert_eq!(m.row_variance_tr(), Vector3::new(4.5, 4.5, 4.5)); + /// assert_eq!(m.row_variance_tr(), Vector3::new(2.25, 2.25, 2.25)); /// ``` #[inline] pub fn row_variance_tr(&self) -> VectorN @@ -246,6 +252,8 @@ impl> Matrix { /// The mean of all the rows of this matrix. /// + /// Use `.row_mean_tr` if you need the result in a column vector instead. + /// /// # Example /// /// ```