R/CDM_rmvnorm.R

Defines functions CDM_rmvnorm

Documented in CDM_rmvnorm

## File Name: CDM_rmvnorm.R
## File Version: 0.03


CDM_rmvnorm <- function(n, mean=NULL, sigma, ...)
{
    add_means <- FALSE
    if ( missing(n) ){
        n <- nrow(mean)
        add_means <- TRUE
        mean0 <- mean
        mean <- rep(0,ncol(mean))
    }
    if (is.null(mean)){
        mean <- rep(0,ncol(sigma) )
    }
    x <- mvtnorm::rmvnorm(n=n, mean=mean, sigma=sigma, ...)
    if (n==1){
        x <- as.vector(x)
    }
    if (add_means){
        x <- x + mean0
    }
    return(x)
}

Try the CDM package in your browser

Any scripts or data that you put into this service are public.

CDM documentation built on Aug. 25, 2022, 5:08 p.m.