DistributionFunction() public method

Gets the cumulative distribution function (cdf) for the this distribution evaluated at point x.

The Cumulative Distribution Function (CDF) describes the cumulative probability that a given value or any value smaller than it will occur.

The calculation is computed through the relationship to the function as erfc(-z/sqrt(2)) / 2.

References: http://mathworld.wolfram.com/NormalDistributionFunction.html

public DistributionFunction ( double x ) : double
x double /// A single point in the distribution range.
return double
Ejemplo n.º 1
0
        /// <summary>
        ///   Gets the cumulative distribution function (cdf) for
        ///   this distribution evaluated at point <c>k</c>.
        /// </summary>
        ///
        /// <param name="x">A single point in the distribution range.</param>
        ///
        /// <remarks>
        ///   The Cumulative Distribution Function (CDF) describes the cumulative
        ///   probability that a given value or any value smaller than it will occur.
        /// </remarks>
        ///
        protected internal override double InnerDistributionFunction(double x)
        {
            if (this.exact)
            {
                return(exactMethod(x, table));
            }

            if (Correction == ContinuityCorrection.Midpoint)
            {
                if (x > Mean)
                {
                    x = x - 0.5;
                }
                else
                {
                    x = x + 0.5;
                }
            }
            else if (Correction == ContinuityCorrection.KeepInside)
            {
                x = x + 0.5;
            }

            return(approximation.DistributionFunction(x));
        }
Ejemplo n.º 2
0
        private double distributionFunction(double x)
        {
            if (exact)
            {
                // For small samples (< 30) and if there are not very large
                // differences in samples sizes, this distribution is exact.
                return(WilcoxonDistribution.exactMethod(x, table));
            }

            if (Correction == ContinuityCorrection.Midpoint)
            {
                if (x > Mean)
                {
                    x = x - 0.5;
                }
                else
                {
                    x = x + 0.5;
                }
            }
            else if (Correction == ContinuityCorrection.KeepInside)
            {
                x = x + 0.5;
            }

            return(approximation.DistributionFunction(x));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///   Gets the cumulative distribution function (cdf) for
        ///   this distribution evaluated at point <c>x</c>.
        /// </summary>
        ///
        /// <param name="x">A single point in the distribution range.</param>
        ///
        /// <remarks>
        ///   The Cumulative Distribution Function (CDF) describes the cumulative
        ///   probability that a given value or any value smaller than it will occur.
        /// </remarks>
        ///
        /// <example>
        ///   See <see cref="KolmogorovSmirnovDistribution"/>.
        /// </example>
        ///
        public override double DistributionFunction(double x)
        {
            if (x <= 0)
            {
                return(1);
            }
            if (x >= 1)
            {
                return(0);
            }

            double z   = g(x);
            double cdf = normal.DistributionFunction(z);

            return(cdf);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Gets the complementary cumulative distribution function
        ///   (ccdf) for this distribution evaluated at point <c>x</c>.
        ///   This function is also known as the Survival function.
        /// </summary>
        ///
        /// <param name="x">A single point in the distribution range.</param>
        ///
        /// <remarks>
        ///   The Complementary Cumulative Distribution Function (CCDF) is
        ///   the complement of the Cumulative Distribution Function, or 1
        ///   minus the CDF.
        /// </remarks>
        ///
        protected internal override double InnerComplementaryDistributionFunction(double x)
        {
            double z = g(x);

            return(normal.DistributionFunction(z));
        }
        public void DistributionFunctionTest1()
        {
            var target = GeneralizedNormalDistribution.Normal(mean: 0.42, stdDev: 4.2);
            var normal = new NormalDistribution(mean: 0.42, stdDev: 4.2);

            for (double x = -10; x < 10; x += 0.0001)
            {
                double actual = target.DistributionFunction(x);
                double expected = normal.DistributionFunction(x);
                Assert.AreEqual(expected, actual, 1e-10);
                Assert.IsFalse(Double.IsNaN(actual));
            }
        }
        public void ConstructorTest2()
        {
            var original = new NormalDistribution(mean: 4, stdDev: 4.2);

            var normal = GeneralContinuousDistribution.FromDensityFunction(
                original.Support, original.ProbabilityDensityFunction);

            for (double i = -10; i < +10; i += 0.1)
            {
                double expected = original.DistributionFunction(i);
                double actual = normal.DistributionFunction(i);

                double diff = Math.Abs(expected - actual) / expected;
                Assert.IsTrue(diff < 1e-7);
            }

            testNormal(normal, 1);
        }
Ejemplo n.º 7
0
        public void DistributionFunctionTest3()
        {
            double expected, actual;

            // Test small variance
            NormalDistribution target = new NormalDistribution(1.0, double.Epsilon);

            expected = 0;
            actual = target.DistributionFunction(0);
            Assert.AreEqual(expected, actual);

            expected = 0.5;
            actual = target.DistributionFunction(1.0);
            Assert.AreEqual(expected, actual);

            expected = 1.0;
            actual = target.DistributionFunction(1.0 + 1e-15);
            Assert.AreEqual(expected, actual);

            expected = 0.0;
            actual = target.DistributionFunction(1.0 - 1e-15);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public void DistributionFunctionTest()
        {
            double x = 3;
            double mean = 7;
            double dev = 5;

            NormalDistribution target = new NormalDistribution(mean, dev);

            double expected = 0.211855398583397;
            double actual = target.DistributionFunction(x);

            Assert.IsFalse(double.IsNaN(actual));
            Assert.AreEqual(expected, actual, 1e-15);
        }
 /// <summary>
 ///   Gets the cumulative distribution function (cdf) for
 ///   this distribution evaluated at point <c>x</c>.
 /// </summary>
 ///
 /// <param name="x">A single point in the distribution range.</param>
 ///
 /// <remarks>
 ///   The Cumulative Distribution Function (CDF) describes the cumulative
 ///   probability that a given value or any value smaller than it will occur.
 /// </remarks>
 ///
 /// <example>
 ///   See <see cref="KolmogorovSmirnovDistribution"/>.
 /// </example>
 ///
 public override double DistributionFunction(double x)
 {
     return(normal.DistributionFunction(g(x)));
 }