summaryrefslogtreecommitdiff
path: root/packages/base/src
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-10-29 11:39:46 +0100
committerAlberto Ruiz <aruiz@um.es>2015-10-29 11:39:46 +0100
commit3e5f71c9d711fabd0e0c45fc25c58bf34f88fe3b (patch)
treedb5277cfc055cbe87aab1b06abc75d52d7d4b0ab /packages/base/src
parentebf8ce6595c6d11bcc3662e84a32822c2eaaa77a (diff)
parent83f6998b935829a54a5737632af18279adc7665a (diff)
Merge pull request #157 from patrikja/master
meanCov type update to use Herm instead of Matrix
Diffstat (limited to 'packages/base/src')
-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