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.
Parameters:
Psi_par
is $\boldsymbol{\Psi}$nu_par
is $\nu$Definition:
template<typename mT, typename pT> statslib_inline return_t<pT> dinvwish(const mT& X, const mT& Psi_par, const pT nu_par, bool log_form = false);
Computes the density function.
Examples:
// parameters arma::mat Psi = arma::eye(5,5); double nu = 10.0; // Armadillo input arma::mat X(10,1); X.fill(2.5); arma::mat dens_vals_mat = stats::dinvwish(X,Psi,nu); arma::mat log_dens_vals_mat = stats::dinvwish(X,Psi,nu,true);
Definition:
template<typename mT, typename pT> statslib_inline mT rinvwish(const mT& Psi_par, const pT nu_par, const bool pre_chol = false);
Generates pseudo-random draws.
Here pre_chol
indicates whether Psi_par
is being passed as a Cholesky decomposition (in lower triangular format).
Examples:
// parameters arma::mat Psi = arma::eye(5,5); double nu = 10.0; // Armadillo output arma::mat rand_mat = stats::rinvwish<arma::mat>(Psi,nu);