public void ConstructorTest2() { var exp = new ExponentialDistribution(rate: 0.42); double mean = exp.Mean; // 2.3809523809523809 double median = exp.Median; // 1.6503504299046317 double var = exp.Variance; // 5.6689342403628125 double cdf = exp.DistributionFunction(x: 0.27); // 0.10720652870550407 double pdf = exp.ProbabilityDensityFunction(x: 0.27); // 0.3749732579436883 double lpdf = exp.LogProbabilityDensityFunction(x: 0.27); // -0.98090056770472311 double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593 double icdf = exp.InverseDistributionFunction(p: cdf); // 0.27 double hf = exp.HazardFunction(x: 0.27); // 0.42 double chf = exp.CumulativeHazardFunction(x: 0.27); // 0.1134 string str = exp.ToString(CultureInfo.InvariantCulture); // Exp(x; λ = 0.42) Assert.AreEqual(2.3809523809523809, mean); Assert.AreEqual(1.6503504299046317, median); Assert.AreEqual(5.6689342403628125, var); Assert.AreEqual(0.1134, chf); Assert.AreEqual(0.10720652870550407, cdf); Assert.AreEqual(0.3749732579436883, pdf); Assert.AreEqual(-0.98090056770472311, lpdf); Assert.AreEqual(0.42, hf); Assert.AreEqual(0.89279347129449593, ccdf); Assert.AreEqual(0.27, icdf); Assert.AreEqual("Exp(x; λ = 0.42)", str); }
public void ConstructorTest2() { var exp = new ExponentialDistribution(rate: 0.42); double mean = exp.Mean; // 2.3809523809523809 double median = exp.Median; // 1.6503504299046317 double var = exp.Variance; // 5.6689342403628125 double mode = exp.Mode; // 0.0 double cdf = exp.DistributionFunction(x: 0.27); // 0.10720652870550407 double pdf = exp.ProbabilityDensityFunction(x: 0.27); // 0.3749732579436883 double lpdf = exp.LogProbabilityDensityFunction(x: 0.27); // -0.98090056770472311 double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593 double icdf = exp.InverseDistributionFunction(p: cdf); // 0.27 double hf = exp.HazardFunction(x: 0.27); // 0.42 double chf = exp.CumulativeHazardFunction(x: 0.27); // 0.1134 string str = exp.ToString(CultureInfo.InvariantCulture); // Exp(x; λ = 0.42) Assert.AreEqual(2.3809523809523809, mean); Assert.AreEqual(1.6503504299046317, median); Assert.AreEqual(0.0, mode); Assert.AreEqual(5.6689342403628125, var); Assert.AreEqual(0.1134, chf); Assert.AreEqual(0.10720652870550407, cdf); Assert.AreEqual(0.3749732579436883, pdf); Assert.AreEqual(-0.98090056770472311, lpdf); Assert.AreEqual(0.42, hf); Assert.AreEqual(0.89279347129449593, ccdf); Assert.AreEqual(0.27, icdf); Assert.AreEqual("Exp(x; λ = 0.42)", str); var range1 = exp.GetRange(0.95); var range2 = exp.GetRange(0.99); var range3 = exp.GetRange(0.01); Assert.AreEqual(0.12212689139892995, range1.Min); Assert.AreEqual(7.1326958894142622, range1.Max); Assert.AreEqual(0.023929371079765359, range2.Min); Assert.AreEqual(10.964690919019265, range2.Max); Assert.AreEqual(0.023929371079765359, range3.Min); Assert.AreEqual(10.964690919019265, range3.Max); }
public void MedianTest() { ExponentialDistribution target = new ExponentialDistribution(2.5); Assert.AreEqual(target.Median, target.InverseDistributionFunction(0.5)); }
public static double qnorm(double p) { return(_norm.InverseDistributionFunction(p)); }