コード例 #1
0
        public void ConstructorTest()
        {
            var pareto = new ParetoDistribution(scale: 0.42, shape: 3);

            double mean = pareto.Mean;     // 0.63
            double median = pareto.Median; // 0.52916684095584676
            double var = pareto.Variance;  // 0.13229999999999997

            double cdf = pareto.DistributionFunction(x: 1.4); // 0.973
            double pdf = pareto.ProbabilityDensityFunction(x: 1.4); // 0.057857142857142857
            double lpdf = pareto.LogProbabilityDensityFunction(x: 1.4); // -2.8497783609309111

            double ccdf = pareto.ComplementaryDistributionFunction(x: 1.4); // 0.027000000000000024
            double icdf = pareto.InverseDistributionFunction(p: cdf); // 1.4000000446580794

            double hf = pareto.HazardFunction(x: 1.4); // 2.142857142857141
            double chf = pareto.CumulativeHazardFunction(x: 1.4); // 3.6119184129778072

            string str = pareto.ToString(CultureInfo.InvariantCulture); // Pareto(x; xm = 0.42, α = 3)

            Assert.AreEqual(0.63, mean);
            Assert.AreEqual(0.52916684095584676, median);
            Assert.AreEqual(0.13229999999999997, var);
            Assert.AreEqual(3.6119184129778072, chf);
            Assert.AreEqual(0.973, cdf);
            Assert.AreEqual(0.057857142857142857, pdf);
            Assert.AreEqual(-2.8497783609309111, lpdf);
            Assert.AreEqual(2.142857142857141, hf);
            Assert.AreEqual(0.027000000000000024, ccdf);
            Assert.AreEqual(1.40, icdf, 1e-7);
            Assert.AreEqual("Pareto(x; xm = 0.42, α = 3)", str);
        }
コード例 #2
0
        public void ConstructorTest()
        {
            var pareto = new ParetoDistribution(scale: 0.42, shape: 3);

            double mean = pareto.Mean;     // 0.63
            double median = pareto.Median; // 0.52916684095584676
            double var = pareto.Variance;  // 0.13229999999999997
            double mode = pareto.Mode;     // 0.42

            double cdf = pareto.DistributionFunction(x: 1.4); // 0.973
            double pdf = pareto.ProbabilityDensityFunction(x: 1.4); // 0.057857142857142857
            double lpdf = pareto.LogProbabilityDensityFunction(x: 1.4); // -2.8497783609309111

            double ccdf = pareto.ComplementaryDistributionFunction(x: 1.4); // 0.027000000000000024
            double icdf = pareto.InverseDistributionFunction(p: cdf); // 1.4000000446580794

            double hf = pareto.HazardFunction(x: 1.4); // 2.142857142857141
            double chf = pareto.CumulativeHazardFunction(x: 1.4); // 3.6119184129778072

            string str = pareto.ToString(CultureInfo.InvariantCulture); // Pareto(x; xm = 0.42, α = 3)

            Assert.AreEqual(0.63, mean);
            Assert.AreEqual(0.52916684095584676, median);
            Assert.AreEqual(0.13229999999999997, var);
            Assert.AreEqual(0.42, mode, 1e-10);
            Assert.AreEqual(3.6119184129778072, chf);
            Assert.AreEqual(0.973, cdf);
            Assert.AreEqual(0.057857142857142857, pdf);
            Assert.AreEqual(-2.8497783609309111, lpdf);
            Assert.AreEqual(2.142857142857141, hf);
            Assert.AreEqual(0.027000000000000024, ccdf);
            Assert.AreEqual(1.40, icdf, 1e-7);
            Assert.AreEqual("Pareto(x; xm = 0.42, α = 3)", str);

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

            Assert.AreEqual(0.42724297039643383, range1.Min, 1e-8);
            Assert.AreEqual(1.1400554029735852, range1.Max, 1e-8);
            Assert.AreEqual(0.42140940651872005, range2.Min, 1e-8);
            Assert.AreEqual(1.9494675279346789, range2.Max, 1e-8);
            Assert.AreEqual(0.42140940651872005, range3.Min, 1e-8);
            Assert.AreEqual(1.9494675279346789, range3.Max, 1e-8);
        }