Accord.Tests.Statistics.HypergeometricDistributionTest.HypergeometricDistributionConstructorTest C# (CSharp) Method

HypergeometricDistributionConstructorTest() private method

private HypergeometricDistributionConstructorTest ( ) : void
return void
        public void HypergeometricDistributionConstructorTest()
        {
            bool thrown;

            thrown = false;
            try { new HypergeometricDistribution(10, 0, 11); }
            catch (ArgumentException) { thrown = true; }
            Assert.IsTrue(thrown);

            thrown = false;
            try { new HypergeometricDistribution(10, 11, 9); }
            catch (ArgumentException) { thrown = true; }
            Assert.IsTrue(thrown);

            thrown = false;
            try { new HypergeometricDistribution(0, 0, 1); }
            catch (ArgumentException) { thrown = true; }
            Assert.IsTrue(thrown);

            thrown = false;
            try { new HypergeometricDistribution(1, 0, 0); }
            catch (ArgumentException) { thrown = true; }
            Assert.IsTrue(thrown);

            thrown = false;
            try { new HypergeometricDistribution(1, -1, 1); }
            catch (ArgumentException) { thrown = true; }
            Assert.IsTrue(thrown);

            int N = 10;
            int n = 8;
            int m = 9;

            var target = new HypergeometricDistribution(N, m, n);
            Assert.AreEqual(N, target.PopulationSize);
            Assert.AreEqual(n, target.SampleSize);
            Assert.AreEqual(m, target.PopulationSuccess);

            double dN = N;
            double dn = n;
            double dm = m;

            Assert.AreEqual(dn * (dm / dN), target.Mean);
            Assert.AreEqual(dn * dm * (dN - dm) * (dN - dn) / (dN * dN * (dN - 1.0)), target.Variance);
        }