public void ValidateCumulativeDistribution(double lower, double upper)
        {
            var n = new ContinuousUniform(lower, upper);

            for (var i = 0; i < 11; i++)
            {
                var x = i - 5.0;
                if (x <= lower)
                {
                    Assert.AreEqual(0.0, n.CumulativeDistribution(x));
                    Assert.AreEqual(0.0, ContinuousUniform.CDF(lower, upper, x));
                }
                else if (x >= upper)
                {
                    Assert.AreEqual(1.0, n.CumulativeDistribution(x));
                    Assert.AreEqual(1.0, ContinuousUniform.CDF(lower, upper, x));
                }
                else
                {
                    Assert.AreEqual((x - lower) / (upper - lower), n.CumulativeDistribution(x));
                    Assert.AreEqual((x - lower) / (upper - lower), ContinuousUniform.CDF(lower, upper, x));
                }
            }
        }
Пример #2
0
 /// <summary>
 ///     Computes the cumulative distribution (CDF) of the distribution at x given a certain mean, i.e. P(X ≤ x | μ = mean).
 /// </summary>
 /// <param name="mean">The mean (μ) of the distribution.</param>
 /// <param name="x">The location at which to compute the cumulative distribution function.</param>
 /// <returns>The cumulative distribution at location x.</returns>
 public double CDF(double mean, double x)
 {
     return(ContinuousUniform.CDF(mean - (0.5 * this.rangelength), mean + (0.5 * this.rangelength), x));
 }