Accord.Statistics.Distributions.Multivariate.InverseWishartDistribution.InverseWishartDistribution C# (CSharp) Method

InverseWishartDistribution() public method

Creates a new Inverse Wishart distribution.
public InverseWishartDistribution ( double degreesOfFreedom, double inverseScale ) : System
degreesOfFreedom double The degrees of freedom v.
inverseScale double The inverse scale matrix Ψ (psi).
return System
        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;
        }