Пример #1
0
        public void ConstructorTest()
        {
            var F = new FDistribution(degrees1: 8, degrees2: 5);

            double mean   = F.Mean;                                     // 1.6666666666666667
            double median = F.Median;                                   // 1.0545096252132447
            double var    = F.Variance;                                 // 7.6388888888888893

            double cdf  = F.DistributionFunction(x: 0.27);              // 0.049463408057268315
            double pdf  = F.ProbabilityDensityFunction(x: 0.27);        // 0.45120469723580559
            double lpdf = F.LogProbabilityDensityFunction(x: 0.27);     // -0.79583416831212883

            double ccdf = F.ComplementaryDistributionFunction(x: 0.27); // 0.95053659194273166
            double icdf = F.InverseDistributionFunction(p: cdf);        // 0.27

            double hf  = F.HazardFunction(x: 0.27);                     // 0.47468419528555084
            double chf = F.CumulativeHazardFunction(x: 0.27);           // 0.050728620222091653

            string str = F.ToString(CultureInfo.InvariantCulture);      // F(x; df1 = 8, df2 = 5)

            Assert.AreEqual(1.6666666666666667, mean);
            Assert.AreEqual(1.0545096252132447, median);
            Assert.AreEqual(7.6388888888888893, var);
            Assert.AreEqual(0.050728620222091653, chf);
            Assert.AreEqual(0.049463408057268315, cdf);
            Assert.AreEqual(0.45120469723580559, pdf);
            Assert.AreEqual(-0.79583416831212883, lpdf);
            Assert.AreEqual(0.47468419528555084, hf);
            Assert.AreEqual(0.95053659194273166, ccdf);
            Assert.AreEqual(0.27, icdf);
            Assert.AreEqual("F(x; df1 = 8, df2 = 5)", str);
        }
Пример #2
0
        public void ConstructorTest()
        {
            var F = new FDistribution(degrees1: 8, degrees2: 5);

            double mean   = F.Mean;                                     // 1.6666666666666667
            double median = F.Median;                                   // 1.0545096252132447
            double var    = F.Variance;                                 // 7.6388888888888893
            double mode   = F.Mode;                                     // 0.5357142857142857

            double cdf  = F.DistributionFunction(x: 0.27);              // 0.049463408057268315
            double pdf  = F.ProbabilityDensityFunction(x: 0.27);        // 0.45120469723580559
            double lpdf = F.LogProbabilityDensityFunction(x: 0.27);     // -0.79583416831212883

            double ccdf = F.ComplementaryDistributionFunction(x: 0.27); // 0.95053659194273166
            double icdf = F.InverseDistributionFunction(p: cdf);        // 0.27

            double hf  = F.HazardFunction(x: 0.27);                     // 0.47468419528555084
            double chf = F.CumulativeHazardFunction(x: 0.27);           // 0.050728620222091653

            string str = F.ToString(CultureInfo.InvariantCulture);      // F(x; df1 = 8, df2 = 5)

            Assert.AreEqual(0, F.Support.Min);
            Assert.AreEqual(double.PositiveInfinity, F.Support.Max);

            Assert.AreEqual(F.InverseDistributionFunction(0), F.Support.Min);
            Assert.AreEqual(F.InverseDistributionFunction(1), F.Support.Max);

            Assert.AreEqual(1.6666666666666667, mean);
            Assert.AreEqual(1.0545096252132447, median);
            Assert.AreEqual(7.6388888888888893, var);
            Assert.AreEqual(0.5357142857142857, mode);
            Assert.AreEqual(0.050728620222091653, chf);
            Assert.AreEqual(0.049463408057268315, cdf);
            Assert.AreEqual(0.45120469723580559, pdf);
            Assert.AreEqual(-0.79583416831212883, lpdf);
            Assert.AreEqual(0.47468419528555084, hf);
            Assert.AreEqual(0.95053659194273166, ccdf);
            Assert.AreEqual(0.27, icdf);
            Assert.AreEqual("F(x; df1 = 8, df2 = 5)", str);

            var range1 = F.GetRange(0.95);
            var range2 = F.GetRange(0.99);
            var range3 = F.GetRange(0.01);

            Assert.AreEqual(0.27118653875813753, range1.Min);
            Assert.AreEqual(4.8183195356568689, range1.Max);
            Assert.AreEqual(0.15078805233761733, range2.Min);
            Assert.AreEqual(10.289311046135927, range2.Max);
            Assert.AreEqual(0.1507880523376173, range3.Min);
            Assert.AreEqual(10.289311046135927, range3.Max);
        }