Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ inv_wishart_lpdf() [1/2]

template<bool propto, typename T_y , typename T_dof , typename T_scale >
return_type_t< T_y, T_dof, T_scale > stan::math::inv_wishart_lpdf ( const T_y &  W,
const T_dof &  nu,
const T_scale &  S 
)

The log of the Inverse-Wishart density for the given W, degrees of freedom, and scale matrix.

The scale matrix, S, must be k x k, symmetric, and semi-positive definite.

\begin{eqnarray*} W &\sim& \mbox{\sf{Inv-Wishart}}_{\nu} (S) \\ \log (p (W \, |\, \nu, S) ) &=& \log \left( \left(2^{\nu k/2} \pi^{k (k-1) /4} \prod_{i=1}^k{\Gamma (\frac{\nu + 1 - i}{2})} \right)^{-1} \times \left| S \right|^{\nu/2} \left| W \right|^{-(\nu + k + 1) / 2} \times \exp (-\frac{1}{2} \mbox{tr} (S W^{-1})) \right) \\ &=& -\frac{\nu k}{2}\log(2) - \frac{k (k-1)}{4} \log(\pi) - \sum_{i=1}^{k}{\log (\Gamma (\frac{\nu+1-i}{2}))} +\frac{\nu}{2} \log(\det(S)) - \frac{\nu+k+1}{2}\log (\det(W)) - \frac{1}{2} \mbox{tr}(S W^{-1}) \end{eqnarray*}

Template Parameters
T_ytype of scalar
T_doftype of degrees of freedom
T_scaletype of scale
Parameters
WA scalar matrix
nuDegrees of freedom
SThe scale matrix
Returns
The log of the Inverse-Wishart density at W given nu and S.
Exceptions
std::domain_errorif nu is not greater than k-1
std::domain_errorif S is not square, not symmetric, or not semi-positive definite.

Definition at line 45 of file inv_wishart_lpdf.hpp.