summaryrefslogtreecommitdiff
path: root/lib/Numeric/Container.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/Container.hs')
-rw-r--r--lib/Numeric/Container.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs
index 661e5b4..345c1f1 100644
--- a/lib/Numeric/Container.hs
+++ b/lib/Numeric/Container.hs
@@ -132,3 +132,14 @@ instance LSDiv Matrix Matrix where
132 (<\>) = linearSolveSVD 132 (<\>) = linearSolveSVD
133 133
134-------------------------------------------------------- 134--------------------------------------------------------
135
136-- | Compute mean vector and covariance matrix of the rows of a matrix.
137meanCov :: Matrix Double -> (Vector Double, Matrix Double)
138meanCov x = (med,cov) where
139 r = rows x
140 k = 1 / fromIntegral r
141 med = konst k r `vXm` x
142 meds = konst 1 r `outer` med
143 xc = x `sub` meds
144 cov = scale (recip (fromIntegral (r-1))) (trans xc `mXm` xc)
145