Ejemplo n.º 1
0
        public void ProbabilityDensityFunctionTest()
        {
            TDistribution target   = new TDistribution(1);
            double        expected = 0.31830988618379075;
            double        actual   = target.ProbabilityDensityFunction(0);

            Assert.AreEqual(expected, actual);

            expected = 0.017076710632177614;
            actual   = target.ProbabilityDensityFunction(4.2);
            Assert.AreEqual(expected, actual);

            target   = new TDistribution(2);
            expected = 0.35355339059327379;
            actual   = target.ProbabilityDensityFunction(0);
            Assert.AreEqual(expected, actual);

            expected = 0.011489146700777093;
            actual   = target.ProbabilityDensityFunction(4.2);
            Assert.AreEqual(expected, actual);

            target   = new TDistribution(3);
            expected = 0.36755259694786141;
            actual   = target.ProbabilityDensityFunction(0);
            Assert.AreEqual(expected, actual);

            expected = 0.0077650207237835792;
            actual   = target.ProbabilityDensityFunction(4.2);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void ConstructorTest()
        {
            var t = new TDistribution(degreesOfFreedom: 4.2);

            double mean   = t.Mean;                                    // 0.0
            double median = t.Median;                                  // 0.0
            double var    = t.Variance;                                // 1.9090909090909089

            double cdf  = t.DistributionFunction(x: 1.4);              // 0.88456136730659074
            double pdf  = t.ProbabilityDensityFunction(x: 1.4);        // 0.13894002185341031
            double lpdf = t.LogProbabilityDensityFunction(x: 1.4);     // -1.9737129364307417

            double ccdf = t.ComplementaryDistributionFunction(x: 1.4); // 0.11543863269340926
            double icdf = t.InverseDistributionFunction(p: cdf);       // 1.4000000000000012

            double hf  = t.HazardFunction(x: 1.4);                     // 1.2035833984833988
            double chf = t.CumulativeHazardFunction(x: 1.4);           // 2.1590162088918525

            string str = t.ToString(CultureInfo.InvariantCulture);     // T(x; df = 4.2)

            Assert.AreEqual(0.0, mean);
            Assert.AreEqual(0.0, median);
            Assert.AreEqual(1.9090909090909089, var);
            Assert.AreEqual(2.1590162088918525, chf);
            Assert.AreEqual(0.88456136730659074, cdf);
            Assert.AreEqual(0.13894002185341031, pdf);
            Assert.AreEqual(-1.9737129364307417, lpdf);
            Assert.AreEqual(1.2035833984833988, hf);
            Assert.AreEqual(0.11543863269340926, ccdf);
            Assert.AreEqual(1.4000000000000012, icdf);
            Assert.AreEqual("T(x; df = 4.2)", str);
        }
Ejemplo n.º 3
0
        public void ConstructorTest()
        {
            var t = new TDistribution(degreesOfFreedom: 4.2);

            double mean   = t.Mean;     // 0.0
            double median = t.Median;   // 0.0
            double var    = t.Variance; // 1.9090909090909089
            double mode   = t.Mode;

            double cdf  = t.DistributionFunction(x: 1.4);              // 0.88456136730659074
            double pdf  = t.ProbabilityDensityFunction(x: 1.4);        // 0.13894002185341031
            double lpdf = t.LogProbabilityDensityFunction(x: 1.4);     // -1.9737129364307417

            double ccdf = t.ComplementaryDistributionFunction(x: 1.4); // 0.11543863269340926
            double icdf = t.InverseDistributionFunction(p: cdf);       // 1.4000000000000012

            double hf  = t.HazardFunction(x: 1.4);                     // 1.2035833984833988
            double chf = t.CumulativeHazardFunction(x: 1.4);           // 2.1590162088918525

            string str = t.ToString(CultureInfo.InvariantCulture);     // T(x; df = 4.2)

            Assert.AreEqual(double.NegativeInfinity, t.Support.Min);
            Assert.AreEqual(double.PositiveInfinity, t.Support.Max);

            double icdf0 = t.InverseDistributionFunction(0);
            double icdf1 = t.InverseDistributionFunction(1);

            Assert.AreEqual(icdf0, t.Support.Min);
            Assert.AreEqual(icdf1, t.Support.Max);

            Assert.AreEqual(0.0, mean);
            Assert.AreEqual(0.0, median);
            Assert.AreEqual(0.0, mode);
            Assert.AreEqual(1.9090909090909089, var);
            Assert.AreEqual(2.1590162088918525, chf);
            Assert.AreEqual(0.88456136730659074, cdf);
            Assert.AreEqual(0.13894002185341031, pdf);
            Assert.AreEqual(-1.9737129364307417, lpdf);
            Assert.AreEqual(1.2035833984833988, hf);
            Assert.AreEqual(0.11543863269340926, ccdf);
            Assert.AreEqual(1.4000000000000012, icdf);
            Assert.AreEqual("T(x; df = 4.2)", str);

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

            Assert.AreEqual(-2.1030107450099362, range1.Min);
            Assert.AreEqual(2.1030107450099362, range1.Max);
            Assert.AreEqual(-3.6502571302187774, range2.Min);
            Assert.AreEqual(3.6502571302187774, range2.Max);
            Assert.AreEqual(-3.6502571302187792, range3.Min);
            Assert.AreEqual(3.6502571302187774, range3.Max);
        }
 protected override double InnerProbabilityDensityFunction(double x)
 {
     return(baseT.ProbabilityDensityFunction((x - mean) / ScaleCoefficient) / ScaleCoefficient);
 }
 private double IntegralFunction(double x)
 {
     return(ts * ((x * baseDistribution.DistributionFunction(x)) + (baseDistribution.ProbabilityDensityFunction(x) * (df + Math.Pow(x, 2)) / (df - 1d))));
 }