Accord.Tests.Statistics.ToolsTest.MahalanobisTest C# (CSharp) Method

MahalanobisTest() private method

private MahalanobisTest ( ) : void
return void
        public void MahalanobisTest()
        {
            double[] x = { 1, 0 };
            double[,] y = 
            {
                { 1, 0 },
                { 0, 8 },
                { 0, 5 }
            };

            // Computing the mean of y
            double[] meanY = Measures.Mean(y, dimension: 0);

            // Computing the covariance matrix of y
            double[,] covY = Measures.Covariance(y, meanY);

            // Inverting the covariance matrix
            double[,] precision = covY.Inverse();

            // Run actual test
            double expected = 1.33333;
            double actual = Distance.SquareMahalanobis(x, meanY, precision);

            Assert.AreEqual(expected, actual, 0.0001);
        }