Permalink
Browse files

Adapt mvrnorm for FlashR.

  • Loading branch information...
zheng-da committed Nov 23, 2016
1 parent 9c7eb40 commit 7143368ecfd8426cdb2197ffa1b2226fd435a024
Showing with 2 additions and 2 deletions.
  1. +2 −2 R/mvrnorm.R
View
@@ -23,10 +23,10 @@ mvrnorm <-
eS <- eigen(Sigma, symmetric = TRUE) eS <- eigen(Sigma, symmetric = TRUE)
ev <- eS$values ev <- eS$values
if(!all(ev >= -tol*abs(ev[1L]))) stop("'Sigma' is not positive definite") if(!all(ev >= -tol*abs(ev[1L]))) stop("'Sigma' is not positive definite")
X <- matrix(rnorm(p * n), n) X <- fm.rnorm.matrix(n, p)
if(empirical) { if(empirical) {
X <- scale(X, TRUE, FALSE) # remove means X <- scale(X, TRUE, FALSE) # remove means
X <- X %*% svd(X, nu = 0)$v # rotate to PCs X <- X %*% fm.svd(X, nu = 0)$v # rotate to PCs
X <- scale(X, FALSE, TRUE) # rescale PCs to unit variance X <- scale(X, FALSE, TRUE) # rescale PCs to unit variance
} }
X <- drop(mu) + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X) X <- drop(mu) + eS$vectors %*% diag(sqrt(pmax(ev, 0)), p) %*% t(X)

0 comments on commit 7143368

Please sign in to comment.