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

WishartDistribution() public method

Creates a new Wishart distribution.
public WishartDistribution ( double degreesOfFreedom, double scale ) : System
degreesOfFreedom double The degrees of freedom n.
scale double The positive-definite matrix scale matrix V.
return System
        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;
        }