Пример #1
0
        public double GetSDNLL_MDF(ILArray <double> mdfVector)
        {
            double firstPart  = 0;
            double secondPart = 0;
            double thirdPart  = 0;

            if (this.items.Count < 2)
            {
                this.covarianceMatrixMDF = this.GetVarianceMatrix_MDF();
            }

            int q = this.meanMDF.Length;

            // get matrix W
            ILArray <double> W        = this.GetMatrixW_MDF();
            ILArray <double> WInverse = this.GetInverseMatrixOfMatrix(W, q);

            /*if (Double.IsNaN(WInverse.ToArray()[0]))
             * {
             *  //throw new InvalidDataException("inverse of covariance matrix MDF is NaN");
             *  WInverse = ILMath.eye(this.parent.VarianceMDF.Length, this.parent.VarianceMDF.Length);
             *  Debug.Assert(true, "Problem with covariance gaussian matrix.");
             * }*/


            ILArray <double> vector1  = mdfVector - this.meanMDF;
            ILArray <double> tmpArray = ILMath.multiply(WInverse, vector1);

            firstPart  = 0.5 * ILMath.multiply(vector1.T, tmpArray).ToArray()[0];
            secondPart = q / 2 * ILMath.log(2 * Math.PI).ToArray()[0];
            thirdPart  = 0.5 * ILMath.log(ILMath.det(W)).ToArray()[0];

            return(firstPart + secondPart + thirdPart);
        }