22.1 Multivariate Normal Distribution
22.1.1 Probability Density Function
If K∈N, μ∈RK, and Σ∈RK×K is symmetric and positive definite, then for y∈RK, MultiNormal(y|μ,Σ)=1(2π)K/2 1√|Σ| exp(−12(y−μ)⊤Σ−1(y−μ)), where |Σ| is the absolute determinant of Σ.
22.1.2 Sampling Statement
y ~
multi_normal
(mu, Sigma)
Increment target log probability density with multi_normal_lpdf( y | mu, Sigma)
dropping constant additive terms.
22.1.3 Stan Functions
The multivariate normal probability function is overloaded to allow the variate vector y and location vector μ to be vectors or row vectors (or to mix the two types). The density function is also vectorized, so it allows arrays of row vectors or vectors as arguments; see section vectorized function signatures for a description of vectorization.
real
multi_normal_lpdf
(vectors y | vectors mu, matrix Sigma)
The log of the multivariate normal density of vector(s) y given
location vector(s) mu and covariance matrix Sigma
real
multi_normal_lpdf
(vectors y | row_vectors mu, matrix Sigma)
The log of the multivariate normal density of vector(s) y given
location row vector(s) mu and covariance matrix Sigma
real
multi_normal_lpdf
(row_vectors y | vectors mu, matrix Sigma)
The log of the multivariate normal density of row vector(s) y given
location vector(s) mu and covariance matrix Sigma
real
multi_normal_lpdf
(row_vectors y | row_vectors mu, matrix Sigma)
The log of the multivariate normal density of row vector(s) y given
location row vector(s) mu and covariance matrix Sigma
Although there is a direct multi-normal RNG function, if more than one
result is required, it’s much more efficient to Cholesky factor the
covariance matrix and call multi_normal_cholesky_rng
; see section
multi-variate normal, cholesky parameterization.
vector
multi_normal_rng
(vector mu, matrix Sigma)
Generate a multivariate normal variate with location mu and covariance
matrix Sigma; may only be used in transformed data and generated quantities blocks
vector
multi_normal_rng
(row_vector mu, matrix Sigma)
Generate a multivariate normal variate with location mu and covariance
matrix Sigma; may only be used in transformed data and generated quantities blocks
vectors
multi_normal_rng
(vectors mu, matrix Sigma)
Generate an array of multivariate normal variates with locations mu
and covariance matrix Sigma; may only be used in transformed data and generated
quantities blocks
vectors
multi_normal_rng
(row_vectors mu, matrix Sigma)
Generate an array of multivariate normal variates with locations mu
and covariance matrix Sigma; may only be used in transformed data and generated
quantities blocks