diff options
-rw-r--r-- | lib/Data/Packed/Random.hs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Data/Packed/Random.hs b/lib/Data/Packed/Random.hs index fea3cdd..7e0f91f 100644 --- a/lib/Data/Packed/Random.hs +++ b/lib/Data/Packed/Random.hs | |||
@@ -34,12 +34,10 @@ gaussianSample :: Int -- ^ seed | |||
34 | -> Matrix Double -- ^ covariance matrix | 34 | -> Matrix Double -- ^ covariance matrix |
35 | -> Matrix Double -- ^ result | 35 | -> Matrix Double -- ^ result |
36 | gaussianSample seed n med cov = m where | 36 | gaussianSample seed n med cov = m where |
37 | (l,v) = eigSH' cov | 37 | c = dim med |
38 | c = dim l | ||
39 | meds = constant 1 n `outer` med | 38 | meds = constant 1 n `outer` med |
40 | rs = reshape c $ randomVector seed Gaussian (c * n) | 39 | rs = reshape c $ randomVector seed Gaussian (c * n) |
41 | ds = sqrt (abs l) | 40 | m = rs <> cholSH cov + meds |
42 | m = rs <> (diag ds <> trans v) + meds | ||
43 | 41 | ||
44 | -- | Obtains a matrix whose rows are pseudorandom samples from a multivariate | 42 | -- | Obtains a matrix whose rows are pseudorandom samples from a multivariate |
45 | -- uniform distribution. | 43 | -- uniform distribution. |