summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/base/src/Internal/Container.hs8
-rw-r--r--packages/gsl/src/Numeric/GSL/Random.hs5
-rw-r--r--packages/tests/src/Numeric/LinearAlgebra/Tests.hs4
3 files changed, 6 insertions, 11 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
diff --git a/packages/gsl/src/Numeric/GSL/Random.hs b/packages/gsl/src/Numeric/GSL/Random.hs
index 139c921..aad9ad9 100644
--- a/packages/gsl/src/Numeric/GSL/Random.hs
+++ b/packages/gsl/src/Numeric/GSL/Random.hs
@@ -39,13 +39,13 @@ type Seed = Int
39gaussianSample :: Seed 39gaussianSample :: Seed
40 -> Int -- ^ number of rows 40 -> Int -- ^ number of rows
41 -> Vector Double -- ^ mean vector 41 -> Vector Double -- ^ mean vector
42 -> Matrix Double -- ^ covariance matrix 42 -> Herm Double -- ^ covariance matrix
43 -> Matrix Double -- ^ result 43 -> Matrix Double -- ^ result
44gaussianSample seed n med cov = m where 44gaussianSample seed n med cov = m where
45 c = size med 45 c = size med
46 meds = konst 1 n `outer` med 46 meds = konst 1 n `outer` med
47 rs = reshape c $ randomVector seed Gaussian (c * n) 47 rs = reshape c $ randomVector seed Gaussian (c * n)
48 m = rs <> cholSH cov + meds 48 m = rs <> chol cov + meds
49 49
50-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate 50-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate
51-- uniform distribution. 51-- uniform distribution.
@@ -87,4 +87,3 @@ rand = randm Uniform
87-} 87-}
88randn :: Int -> Int -> IO (Matrix Double) 88randn :: Int -> Int -> IO (Matrix Double)
89randn = randm Gaussian 89randn = randm Gaussian
90
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
index 4b631cf..56546b6 100644
--- a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
+++ b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
@@ -137,7 +137,7 @@ randomTestGaussian = c :~1~: snd (meanCov dat) where
137 2,4,0, 137 2,4,0,
138 -2,2,1] 138 -2,2,1]
139 m = 3 |> [1,2,3] 139 m = 3 |> [1,2,3]
140 c = a <> tr a 140 c = mTm a
141 dat = gaussianSample 7 (10^6) m c 141 dat = gaussianSample 7 (10^6) m c
142 142
143randomTestUniform = c :~1~: snd (meanCov dat) where 143randomTestUniform = c :~1~: snd (meanCov dat) where
@@ -944,5 +944,3 @@ luBench_2 = do
944 luBenchN_2 luSolve' luPacked' 500 (5::R) "luSolve'.luPacked' Double " 944 luBenchN_2 luSolve' luPacked' 500 (5::R) "luSolve'.luPacked' Double "
945 luBenchN_2 luSolve' luPacked' 500 (5::Mod 9973 I) "luSolve'.luPacked' I mod 9973" 945 luBenchN_2 luSolve' luPacked' 500 (5::Mod 9973 I) "luSolve'.luPacked' I mod 9973"
946 luBenchN_2 luSolve' luPacked' 500 (5::Mod 9973 Z) "luSolve'.luPacked' Z mod 9973" 946 luBenchN_2 luSolve' luPacked' 500 (5::Mod 9973 Z) "luSolve'.luPacked' Z mod 9973"
947
948