Wishart Distribution

Table of contents


Density Function

The density function of the Wishart distribution:

\[f(\mathbf{X}; \boldsymbol{\Psi}, \nu) = \dfrac{1}{2^{\frac{\nu p}{2}} |\boldsymbol{\Psi}|^{\frac{\nu}{2}} \Gamma_p\left( \frac{\nu}{2} \right)} | \mathbf{X} |^{\frac{\nu - p - 1}{2}} \exp \left( - \frac{1}{2} \text{tr} (\boldsymbol{\Psi}^{-1} \mathbf{X}) \right)\]

where \(\Gamma_p\) is the Multivariate Gamma function, \(| \cdot |\) denotes the matrix determinant, and \(\text{tr}(\cdot)\) denotes the matrix trace.

template<typename mT, typename pT, typename not_arma_mat<mT>::type* = nullptr>
inline return_t<pT> dwish(const mT &X, const mT &Psi_par, const pT nu_par, const bool log_form = false)

Density function of the Wishart distribution.

Parameters
  • X – a positive semi-definite matrix.

  • Psi_par – a positive semi-definite scale matrix.

  • nu_par – the degrees of parameter, a real-valued input.

  • log_form – return the log-density or the true form.

Returns

the density function evaluated at X.


Random Sampling

template<typename mT, typename pT, typename not_arma_mat<mT>::type* = nullptr>
inline mT rwish(const mT &Psi_par, const pT nu_par, rand_engine_t &engine, const bool pre_chol = false)

Random sampling function for the Wishart distribution.

Parameters
  • Psi_par – a positive semi-definite scale matrix.

  • nu_par – the degrees of parameter, a real-valued input.

  • engine – a random engine, passed by reference.

  • pre_chol – indicate whether Psi_par is passed in lower triangular (Cholesky) format.

Returns

a pseudo-random draw from the Wishart distribution.