Exemplo n.º 1
0
        public void CookieJar_Example1(int total, int choc1, int choc2, int expectedNumerator, int expectedDenominator)
        {
            var sample1 = new Sample<Cookie>("Jar1");
            var sample2 = new Sample<Cookie>("Jar2");
            var hypos = new HypoSet<Cookie>("All");

            hypos.Add(sample1, sample2);

            sample1.Add(total - choc1, n => new Cookie() { F = 'V' });
            sample1.Add(choc1, n => new Cookie() { F = 'C' });

            sample2.Add(total - choc2, n => new Cookie() { F = 'V' });
            sample2.Add(choc2, n => new Cookie() { F = 'C' });

            var choc = It.IsAny<Cookie>(c => c.F == 'C');
            var vani = It.IsAny<Cookie>(c => c.F == 'V');

            sample1.ProbabilityOfEvent(choc);
            sample2.ProbabilityOfEvent(choc);

            var postProb = hypos.PosterierProbability(sample1, vani);

            Assert.That(postProb.Numerator, Is.EqualTo(expectedNumerator));
            Assert.That(postProb.Denominator, Is.EqualTo(expectedDenominator));
        }