Accord.Tests.Statistics.UnivariateDiscreteDistributionTest.EntropyTest C# (CSharp) Method

EntropyTest() private method

private EntropyTest ( ) : void
return void
        public void EntropyTest()
        {
            UnivariateDiscreteDistribution target = CreateUnivariateDiscreteDistribution();

            double q = 0.42;
            double p = 1 - q;

            double actual = target.Entropy;
            double expected = -q * System.Math.Log(q) - p * System.Math.Log(p);

            Assert.AreEqual(expected, actual);


            target.Fit(new double[] { 0, 1, 0, 0, 1, 0 });

            q = target.Mean;
            p = 1 - q;

            actual = target.Entropy;
            expected = -q * System.Math.Log(q) - p * System.Math.Log(p);

            Assert.AreEqual(expected, actual);
        }