dmvnorm_cpp | R Documentation |
The function dmvnorm()
computes the density of a multivariate normal
distribution.
The function rmvnorm()
samples from a multivariate normal distribution.
The functions with suffix _cpp
perform no input checks, hence are faster.
The univariate normal distribution is available as the special case p = 1
.
dmvnorm_cpp(x, mean, Sigma, log = FALSE)
rmvnorm_cpp(mean, Sigma, log = FALSE)
dmvnorm(x, mean, Sigma, log = FALSE)
rmvnorm(n = 1, mean, Sigma, log = FALSE)
x |
[ |
mean |
[ For |
Sigma |
[ It can also be a zero matrix. For For |
log |
[ For |
n |
[ |
For dmvnorm()
: The density value.
For rmvnorm()
: If n = 1
a vector
of length p
(note
that it is a column vector for rmvnorm_cpp()
), else
a matrix
of dimension n
times p
with samples as rows.
Other simulation helpers:
correlated_regressors()
,
ddirichlet_cpp()
,
dtnorm_cpp()
,
dwishart_cpp()
,
simulate_markov_chain()
x <- c(0, 0)
mean <- c(0, 0)
Sigma <- diag(2)
# compute density
dmvnorm(x = x, mean = mean, Sigma = Sigma)
dmvnorm(x = x, mean = mean, Sigma = Sigma, log = TRUE)
# sample
rmvnorm(n = 3, mean = mean, Sigma = Sigma)
rmvnorm(mean = mean, Sigma = Sigma, log = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.