27.1 Wishart distribution
27.1.1 Probability density function
If \(K \in \mathbb{N}\), \(\nu \in (K-1,\infty)\), and \(S \in \mathbb{R}^{K \times K}\) is symmetric and positive definite, then for symmetric and positive-definite \(W \in \mathbb{R}^{K \times K}\), \[ \text{Wishart}(W|\nu,S) = \frac{1}{2^{\nu K / 2}} \ \frac{1}{\Gamma_K \! \left( \frac{\nu}{2} \right)} \ \left| S \right|^{-\nu/2} \ \left| W \right|^{(\nu - K - 1)/2} \ \exp \! \left(- \frac{1}{2} \ \text{tr}\left( S^{-1} W \right) \right) \! , \] where \(\text{tr}()\) is the matrix trace function, and \(\Gamma_K()\) is the multivariate Gamma function, \[ \Gamma_K(x) = \frac{1}{\pi^{K(K-1)/4}} \ \prod_{k=1}^K \Gamma \left( x + \frac{1 - k}{2} \right) \!. \]
27.1.2 Sampling statement
W ~
wishart
(nu, Sigma)
Increment target log probability density with wishart_lupdf(W | nu, Sigma)
.
Available since 2.0
27.1.3 Stan functions
real
wishart_lpdf
(matrix W | real nu, matrix Sigma)
The log of the Wishart density for symmetric and positive-definite
matrix W given degrees of freedom nu and symmetric and
positive-definite scale matrix Sigma
Available since 2.12
real
wishart_lupdf
(matrix W | real nu, matrix Sigma)
The log of the Wishart density for symmetric and positive-definite
matrix W given degrees of freedom nu and symmetric and
positive-definite scale matrix Sigma dropping constant additive terms
Available since 2.25
matrix
wishart_rng
(real nu, matrix Sigma)
Generate a Wishart variate with degrees of freedom nu and symmetric
and positive-definite scale matrix Sigma; may only be used in
transformed data and generated quantities blocks
Available since 2.0