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