Example #1
0
        public void TestOneSample()
        {
            var fc = new TallySingle(10, -1f, 1f);

            fc.Add(0f);
            Assert.Equal(1f, fc.Probability(0f));
            Assert.Equal(0f, fc.Probability(1f));
            Assert.Equal(0f, ProbabilityDistribution.Entropy(fc.probability));
        }
Example #2
0
        public void TestTwoSamples()
        {
            var fc = new TallySingle(10, -1f, 1f);

            fc.Add(0f);
            fc.Add(0.5f);
            Assert.Equal(0.5f, fc.Probability(0f));
            Assert.Equal(0f, fc.Probability(1f));
            Assert.Equal(0.5f, fc.Probability(0.5f));
            Assert.Equal(0.301f, ProbabilityDistribution.Entropy(fc.probability, fc.binCount), 3);
        }