rcpp_rmvnorm: Multivariate Normal Sampling and Log-Density Evaluation

View source: R/rcpp_mvn.R

rcpp_rmvnormR Documentation

Multivariate Normal Sampling and Log-Density Evaluation

Description

These functions allow for the sampling of and evaluation of the log-density of a multivariate normal vector.

Usage

rcpp_log_dmvnorm(S,mu,x, istoep)
rcpp_rmvnorm(n,S,mu)
rcpp_rmvnorm_Toep(n,S,mu)
rcpp_rmvnorm_stable(n,S,mu)

Arguments

S

Covariance matrix of associated multivariate normal.

n

Number of (independent) samples to generate.

mu

Mean vector.

x

Vector of observations to evaluate the log-density of.

istoep

set this to TRUE if S is Toeplitz.

Author(s)

Giri Gopalan gopalan88@gmail.com

Examples

#See demo/FastGPdemo.R, which includes timing comparisons
set.seed(123)

N <- 5
sigma <- 1 #variance parameter in the covariance function
phi <- 5 #decay parameter for the squared-exponential kernel
x_seq <- seq(N)
Sig <- as.matrix(sigma*exp(-as.matrix(dist(x_seq))^2/phi)) + .001*diag(N) #test covariance function
mu <- rep(0, N)

rcpp_log_dmvnorm(Sig,mu,rep(.1,N), istoep = TRUE)
rcpp_rmvnorm(n=1,Sig,mu)
rcpp_rmvnorm_Toep(n=1,Sig,mu)
rcpp_rmvnorm_stable(n=1,Sig,mu)

FastGP documentation built on Oct. 18, 2026, 1:07 a.m.

Related to rcpp_rmvnorm in FastGP...