From ef333e80b4c4a87ea1b019a5e7c3934366e14c5f Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Sun, 28 Mar 2010 09:42:19 +0000 Subject: randomGaussian using chol --- lib/Data/Packed/Random.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/Data') 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 -> Matrix Double -- ^ covariance matrix -> Matrix Double -- ^ result gaussianSample seed n med cov = m where - (l,v) = eigSH' cov - c = dim l + c = dim med meds = constant 1 n `outer` med rs = reshape c $ randomVector seed Gaussian (c * n) - ds = sqrt (abs l) - m = rs <> (diag ds <> trans v) + meds + m = rs <> cholSH cov + meds -- | Obtains a matrix whose rows are pseudorandom samples from a multivariate -- uniform distribution. -- cgit v1.2.3