public InverseWishartDistribution(double degreesOfFreedom, double[,] inverseScale)
: base(inverseScale.Length)
{
if (inverseScale.GetLength(0) != inverseScale.GetLength(1))
throw new DimensionMismatchException("inverseScale", "Matrix must be square.");
this.inverseScaleMatrix = inverseScale;
this.size = inverseScale.GetLength(0);
this.v = degreesOfFreedom;
if (degreesOfFreedom <= size - 1)
throw new ArgumentOutOfRangeException("degreesOfFreedom", "Degrees of freedom must be greater "
+ "than or equal to the number of rows in the inverse scale matrix.");
var chol = new CholeskyDecomposition(inverseScale);
if (!chol.IsPositiveDefinite)
throw new NonPositiveDefiniteMatrixException("scale");
//if (!chol.Symmetric)
// throw new NonSymmetricMatrixException("scale");
double a = Math.Pow(chol.Determinant, v / 2.0);
double b = Math.Pow(2, (v * size) / 2.0);
double c = Gamma.Multivariate(v / 2.0, size);
this.constant = a / (b * c);
this.power = -(v + size + 1) / 2.0;
}