mvnorm_sd: Draw a sample from a multivariate normal distribution

View source: R/mcmc_functions.R

mvnorm_sdR Documentation

Draw a sample from a multivariate normal distribution

Description

This draws a sample from a multivariate normal distribution with mean vector mu and covariance matrix Sigma. It requires the covariance matrix to be decomposed using spectral decomposition (eigen).

Usage

mvnorm_sd(mu, decomp.covariance)

Arguments

mu

The mean vector

decomp.covariance

This spectral decomposition part of the sampler. It is VU^0.5, where Sigma = VU*t(V). The required component is returned by the construct_constrained_covariance_matrix function.

Value

a vector containing a sample from the distribution

Examples


mu <- c(2, 1) #mean vector
sigma <- matrix(c(2^2, 0.5*2*1, 0.5*2*1, 1^2), 2, 2) #covariacne matrix
sigma.eigen <- eigen(sigma)
decomp.covariance <- sigma.eigen$vectors%*%diag(sqrt(sigma.eigen$values))
f <- mvnorm_sd(mu, decomp.covariance) #draw sample


BSBT documentation built on Aug. 9, 2022, 5:06 p.m.