swh:1:snp:ffdd0a7d2c8ea15ad41d45b3b178f668bd942287
Tip revision: 57f09c35d67acf681aaca0a9b3869bacdcec0585 authored by Derek Young on 30 March 2009, 00:00:00 UTC
version 0.4.1
version 0.4.1
Tip revision: 57f09c3
rmvnormmix.R
# Note: normmixrm.sim is here for backwards compatibility
rmvnormmix <- normmixrm.sim <- function(n,lambda=1,mu=0,sigma=1) {
m <- length(lambda) # nb of components
mu <- matrix(mu, nrow=m)
sigma <- matrix(sigma, nrow=m)
if ((r <- NCOL(mu)) != NCOL(sigma)) {
stop("mu and sigma must have the same number of columns", call.=FALSE)
}
z <- sample(m,n,rep=TRUE,prob=lambda) # component
matrix(rnorm(n*r,mean=as.vector(mu[z,]),sd=as.vector(sigma[z,])),n,r)
}