ProbabilityDensityFunction() public method

Gets the probability density function (pdf) for the Gaussian distribution evaluated at point x.
The Probability Density Function (PDF) describes the probability that a given value x will occur.
public ProbabilityDensityFunction ( double x ) : double
x double A single point in the distribution range. For a /// univariate distribution, this should be a single /// double value. For a multivariate distribution, /// this should be a double array.
return double
Esempio n. 1
0
        /// <summary>
        ///   Gets the probability density function (pdf) for
        ///   this distribution evaluated at point <c>u</c>.
        /// </summary>
        ///
        /// <param name="x">A single point in the distribution range.</param>
        ///
        /// <returns>
        ///   The probability of <c>u</c> occurring
        ///   in the current distribution.
        /// </returns>
        ///
        /// <remarks>
        ///   The Probability Density Function (PDF) describes the
        ///   probability that a given value <c>u</c> will occur.
        /// </remarks>
        ///
        /// <example>
        ///   See <see cref="MannWhitneyDistribution"/>.
        /// </example>
        ///
        protected internal override double InnerProbabilityDensityFunction(double x)
        {
            if (this.exact)
            {
                return(WilcoxonDistribution.count(x, table) / (double)table.Length);
            }

            return(approximation.ProbabilityDensityFunction(x));
        }
Esempio n. 2
0
        /// <summary>
        ///   Gets the probability density function (pdf) for
        ///   this distribution evaluated at point <c>w</c>.
        /// </summary>
        ///
        /// <param name="x">A single point in the distribution range.</param>
        ///
        /// <returns>
        ///   The probability of <c>w</c> occurring
        ///   in the current distribution.
        /// </returns>
        ///
        /// <remarks>
        ///   The Probability Density Function (PDF) describes the
        ///   probability that a given value <c>x</c> will occur.
        /// </remarks>
        ///
        public override double ProbabilityDensityFunction(double x)
        {
            if (this.exact)
            {
                return(count(x, table) / (double)table.Length);
            }

            return(approximation.ProbabilityDensityFunction(x));
        }
        /// <summary>
        ///   Gets the probability density function (pdf) for
        ///   this distribution evaluated at point <c>x</c>.
        /// </summary>
        ///
        /// <param name="x">A single point in the distribution range.</param>
        ///
        /// <returns>
        ///   The probability of <c>x</c> occurring
        ///   in the current distribution.
        /// </returns>
        ///
        /// <remarks>
        ///   The Probability Density Function (PDF) describes the
        ///   probability that a given value <c>x</c> will occur.
        /// </remarks>
        ///
        public override double ProbabilityDensityFunction(double x)
        {
            if (x <= 0 || x >= 1)
            {
                return(0);
            }

            double z = g(x);

            return(normal.ProbabilityDensityFunction(z));
        }
Esempio n. 4
0
        /// <summary>
        ///   Gets the probability density function (pdf) for
        ///   this distribution evaluated at point <c>x</c>.
        /// </summary>
        ///
        /// <param name="x">A single point in the distribution range.</param>
        ///
        /// <returns>
        ///   The probability of <c>x</c> occurring
        ///   in the current distribution.
        /// </returns>
        ///
        /// <remarks>
        ///   The Probability Density Function (PDF) describes the
        ///   probability that a given value <c>x</c> will occur.
        /// </remarks>
        ///
        protected internal override double InnerProbabilityDensityFunction(double x)
        {
            double z = g(x);

            return(normal.ProbabilityDensityFunction(z));
        }
        public void ConstructorTest1()
        {
            var original = new NormalDistribution(mean: 4, stdDev: 4.2);

            var normal = GeneralContinuousDistribution.FromDistributionFunction(
                original.Support, original.DistributionFunction);

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

                double diff = Math.Abs(expected - actual);
                Assert.AreEqual(expected, actual, 1e-6);
            }

            testNormal(normal, 1e3);
        }
Esempio n. 6
0
        public void ProbabilityDensityFunctionTest2()
        {
            double expected, actual;

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

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

            expected = double.PositiveInfinity;
            actual = target.ProbabilityDensityFunction(4.2);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 7
0
        public void ProbabilityDensityFunctionTest()
        {
            double x = 3;
            double mean = 7;
            double dev = 5;

            NormalDistribution target = new NormalDistribution(mean, dev);

            double expected = 0.0579383105522966;
            double actual = target.ProbabilityDensityFunction(x);

            Assert.IsFalse(double.IsNaN(actual));
            Assert.AreEqual(expected, actual, 1e-15);
        }
 /// <summary>
 ///   Gets the probability density function (pdf) for
 ///   this distribution evaluated at point <c>x</c>.
 /// </summary>
 ///
 /// <param name="x">A single point in the distribution range.</param>
 ///
 /// <returns>
 ///   The probability of <c>x</c> occurring
 ///   in the current distribution.
 /// </returns>
 ///
 /// <remarks>
 ///   The Probability Density Function (PDF) describes the
 ///   probability that a given value <c>x</c> will occur.
 /// </remarks>
 ///
 public override double ProbabilityDensityFunction(double x)
 {
     return(normal.ProbabilityDensityFunction(g(x)));
 }
Esempio n. 9
0
        public void InfiniteGaussKronrodTest()
        {
            NormalDistribution norm;
            
            for (int i = -10; i < 10; i++)
            {
                norm = new NormalDistribution(i, 1);

                Func<double, double> E = (x) => x * norm.ProbabilityDensityFunction(x);
                UFunction UE = (x) => x * norm.ProbabilityDensityFunction(x);

                double expected = Quadpack.Integrate(UE, 
                    Double.NegativeInfinity, Double.PositiveInfinity);

                double actual = InfiniteAdaptiveGaussKronrod.Integrate(E,
                    Double.NegativeInfinity, Double.PositiveInfinity);

                Assert.AreEqual(expected, actual, 1e-3);
                Assert.AreEqual(norm.Mean, actual, 1e-3);
            }
        }