Пример #1
0
        public void ConstructorTest()
        {
            var vonMises = new VonMisesDistribution(mean: 0.42, concentration: 1.2);

            double mean   = vonMises.Mean;                                    // 0.42
            double median = vonMises.Median;                                  // 0.42
            double var    = vonMises.Variance;                                // 0.48721760532782921

            double cdf  = vonMises.DistributionFunction(x: 1.4);              // 0.81326928491589345
            double pdf  = vonMises.ProbabilityDensityFunction(x: 1.4);        // 0.2228112141141676
            double lpdf = vonMises.LogProbabilityDensityFunction(x: 1.4);     // -1.5014304395467863

            double ccdf = vonMises.ComplementaryDistributionFunction(x: 1.4); // 0.18673071508410655
            double icdf = vonMises.InverseDistributionFunction(p: cdf);       // 1.3999999637927665

            double hf  = vonMises.HazardFunction(x: 1.4);                     // 1.1932220899695576
            double chf = vonMises.CumulativeHazardFunction(x: 1.4);           // 1.6780877262500649

            string str = vonMises.ToString(CultureInfo.InvariantCulture);     // VonMises(x; μ = 0.42, κ = 1.2)

            double imedian = vonMises.InverseDistributionFunction(p: 0.5);

            Assert.AreEqual(0.42, mean);
            Assert.AreEqual(0.42, median);
            Assert.AreEqual(0.42000000260613551, imedian, 1e-8);
            Assert.AreEqual(0.48721760532782921, var);
            Assert.AreEqual(1.6780877262500649, chf);
            Assert.AreEqual(0.81326928491589345, cdf);
            Assert.AreEqual(0.2228112141141676, pdf);
            Assert.AreEqual(-1.5014304395467863, lpdf);
            Assert.AreEqual(1.1932220899695576, hf);
            Assert.AreEqual(0.18673071508410655, ccdf);
            Assert.AreEqual(1.39999999999, icdf, 1e-8);
            Assert.AreEqual("VonMises(x; μ = 0.42, κ = 1.2)", str);
        }
        public void ConstructorTest()
        {
            var vonMises = new VonMisesDistribution(mean: 0.42, concentration: 1.2);

            double mean   = vonMises.Mean;                                    // 0.42
            double median = vonMises.Median;                                  // 0.42
            double var    = vonMises.Variance;                                // 0.48721760532782921
            double mode   = vonMises.Mode;                                    // 0.42

            double cdf  = vonMises.DistributionFunction(x: 1.4);              // 0.81326928491589345
            double pdf  = vonMises.ProbabilityDensityFunction(x: 1.4);        // 0.2228112141141676
            double lpdf = vonMises.LogProbabilityDensityFunction(x: 1.4);     // -1.5014304395467863

            double ccdf = vonMises.ComplementaryDistributionFunction(x: 1.4); // 0.18673071508410655
            double icdf = vonMises.InverseDistributionFunction(p: cdf);       // 1.3999999637927665

            double hf  = vonMises.HazardFunction(x: 1.4);                     // 1.1932220899695576
            double chf = vonMises.CumulativeHazardFunction(x: 1.4);           // 1.6780877262500649

            string str = vonMises.ToString(CultureInfo.InvariantCulture);     // VonMises(x; μ = 0.42, κ = 1.2)

            double imedian = vonMises.InverseDistributionFunction(p: 0.5);

            Assert.AreEqual(0.42, mean);
            Assert.AreEqual(0.42, median);
            Assert.AreEqual(0.42, mode);
            Assert.AreEqual(0.42000000260613551, imedian, 1e-8);
            Assert.AreEqual(0.48721760532782921, var);
            Assert.AreEqual(1.6780877262500649, chf);
            Assert.AreEqual(0.81326928491589345, cdf);
            Assert.AreEqual(0.2228112141141676, pdf);
            Assert.AreEqual(-1.5014304395467863, lpdf);
            Assert.AreEqual(1.1932220899695576, hf);
            Assert.AreEqual(0.18673071508410655, ccdf);
            Assert.AreEqual(1.39999999999, icdf, 1e-8);
            Assert.AreEqual("VonMises(x; μ = 0.42, κ = 1.2)", str);

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

            Assert.AreEqual(-1.5990672124935188, range1.Min, 1e-14);
            Assert.AreEqual(2.4390672124935207, range1.Max, 1e-14);
            Assert.AreEqual(-2.4355782410688764, range2.Min, 1e-14);
            Assert.AreEqual(3.2755782410688861, range2.Max, 1e-14);
            Assert.AreEqual(-2.4355782410688764, range3.Min, 1e-14);
            Assert.AreEqual(3.2755782410688861, range3.Max, 1e-14);

            Assert.AreEqual(-2.7215926535897932, vonMises.Support.Min, 1e-10);
            Assert.AreEqual(3.561592653589793, vonMises.Support.Max, 1e-10);

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