summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/Container.hs
diff options
context:
space:
mode:
authorPatrik Jansson <patrik.ja@gmail.com>2015-10-28 21:58:44 +0100
committerPatrik Jansson <patrik.ja@gmail.com>2015-10-28 21:58:44 +0100
commit60421ac66146366c6acd984b89475ba10c13e6c6 (patch)
tree4cacaf065179c66f6707e39ddde58cbc0b295970 /packages/base/src/Internal/Container.hs
parentebf8ce6595c6d11bcc3662e84a32822c2eaaa77a (diff)
Better type for meanCov
Diffstat (limited to 'packages/base/src/Internal/Container.hs')
-rw-r--r--packages/base/src/Internal/Container.hs8
1 files changed, 3 insertions, 5 deletions
diff --git a/packages/base/src/Internal/Container.hs b/packages/base/src/Internal/Container.hs
index b08f892..b379530 100644
--- a/packages/base/src/Internal/Container.hs
+++ b/packages/base/src/Internal/Container.hs
@@ -28,7 +28,7 @@ import Internal.Vector
28import Internal.Matrix 28import Internal.Matrix
29import Internal.Element 29import Internal.Element
30import Internal.Numeric 30import Internal.Numeric
31import Internal.Algorithms(Field,linearSolveSVD) 31import Internal.Algorithms(Field,linearSolveSVD,Herm,mTm)
32 32
33------------------------------------------------------------------ 33------------------------------------------------------------------
34 34
@@ -206,14 +206,14 @@ optimiseMult = mconcat
206 , -1.0127225830525157e-2, 3.0373954915729318 ]) 206 , -1.0127225830525157e-2, 3.0373954915729318 ])
207 207
208-} 208-}
209meanCov :: Matrix Double -> (Vector Double, Matrix Double) 209meanCov :: Matrix Double -> (Vector Double, Herm Double)
210meanCov x = (med,cov) where 210meanCov x = (med,cov) where
211 r = rows x 211 r = rows x
212 k = 1 / fromIntegral r 212 k = 1 / fromIntegral r
213 med = konst k r `vXm` x 213 med = konst k r `vXm` x
214 meds = konst 1 r `outer` med 214 meds = konst 1 r `outer` med
215 xc = x `sub` meds 215 xc = x `sub` meds
216 cov = scale (recip (fromIntegral (r-1))) (trans xc `mXm` xc) 216 cov = scale (recip (fromIntegral (r-1))) (mTm xc)
217 217
218-------------------------------------------------------------------------------- 218--------------------------------------------------------------------------------
219 219
@@ -293,5 +293,3 @@ remap i j m
293 | otherwise = error $ "out of range index in remap" 293 | otherwise = error $ "out of range index in remap"
294 where 294 where
295 [i',j'] = conformMs [i,j] 295 [i',j'] = conformMs [i,j]
296
297