Inverse-Wishart Distribution

Table of contents


Density Function

The density function of the inverse-Wishart distribution:

\[f(\mathbf{X}; \boldsymbol{\Psi}, \nu) = \dfrac{|\boldsymbol{\Psi}|^{\frac{\nu}{2}}}{2^{\frac{\nu p}{2}} \Gamma_p\left( \frac{\nu}{2} \right)} | \mathbf{X} |^{-\frac{\nu + p + 1}{2}} \exp \left( - \frac{1}{2} \text{tr} (\boldsymbol{\Psi} \mathbf{X}^{-1}) \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> dinvwish(const mT &X, const mT &Psi_par, const pT nu_par, const bool log_form = false)

Density function of the Inverse-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

Random sampling for the inverse-Wishart distribution is achieved via the method of Feiveson and Odell (1966).

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

Random sampling function for the Inverse-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_inv_chol – indicate whether Psi_par has been inverted and passed in lower triangular (Cholesky) format.

Returns

a pseudo-random draw from the Inverse-Wishart distribution.