public void DiscreteDistributionBase()
        {
            DiscreteDistribution D = new DiscreteTestDistribution();

            double P  = 0.0;
            double M1 = 0.0;
            double M2 = 0.0;

            for (int k = 1; k <= 3; k++)
            {
                P  += D.ProbabilityMass(k);
                M1 += k * D.ProbabilityMass(k);
                M2 += k * k * D.ProbabilityMass(k);
            }
            Assert.IsTrue(TestUtilities.IsNearlyEqual(P, 1.0));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(D.Moment(0), 1.0));

            double C2 = M2 - M1 * M1;

            Assert.IsTrue(TestUtilities.IsNearlyEqual(M1, D.Mean));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(M1, D.Moment(1)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(M2, D.Moment(2)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(C2, D.Variance));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(C2, D.MomentAboutMean(2)));

            Assert.IsTrue(D.InverseLeftProbability(D.LeftInclusiveProbability(2)) == 2);
        }
        public void DiscreteDistributionBase()
        {
            DiscreteDistribution D = new DiscreteTestDistribution();

            double M0 = D.ExpectationValue(k => 1.0);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(M0, 1.0));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(M0, D.RawMoment(0)));

            double M1 = D.ExpectationValue(k => k);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(M1, D.Mean));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(M1, D.RawMoment(1)));

            double C2 = D.ExpectationValue(k => MoreMath.Sqr(k - M1));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(C2, D.Variance));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(C2, D.CentralMoment(2)));

            Assert.IsTrue(D.InverseLeftProbability(D.LeftInclusiveProbability(2)) == 2);
        }
        public void DiscreteDistributionBase()
        {
            DiscreteDistribution D = new DiscreteTestDistribution();

            double P = 0.0;
            double M1 = 0.0;
            double M2 = 0.0;
            for (int k = 1; k <= 3; k++) {
                P += D.ProbabilityMass(k);
                M1 += k * D.ProbabilityMass(k);
                M2 += k * k * D.ProbabilityMass(k);
            }
            Assert.IsTrue(TestUtilities.IsNearlyEqual(P, 1.0));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(D.Moment(0), 1.0));

            double C2 = M2 - M1 * M1;
            Assert.IsTrue(TestUtilities.IsNearlyEqual(M1, D.Mean));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(M1, D.Moment(1)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(M2, D.Moment(2)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(C2, D.Variance));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(C2, D.MomentAboutMean(2)));

            Assert.IsTrue(D.InverseLeftProbability(D.LeftInclusiveProbability(2)) == 2);
        }