public DistributionFunction ( double x ) : double | ||
x | double | A single point in the distribution range. |
리턴 | double |
public void ConstructorTest() { var gompertz = new GompertzDistribution(eta: 4.2, b: 1.1); double median = gompertz.Median; // 0.13886469671401389 double cdf = gompertz.DistributionFunction(x: 0.27); // 0.76599768199799145 double pdf = gompertz.ProbabilityDensityFunction(x: 0.27); // 1.4549484164912097 double lpdf = gompertz.LogProbabilityDensityFunction(x: 0.27); // 0.37497044741163688 double ccdf = gompertz.ComplementaryDistributionFunction(x: 0.27); // 0.23400231800200855 double icdf = gompertz.InverseDistributionFunction(p: cdf); // 0.26999999999766749 double hf = gompertz.HazardFunction(x: 0.27); // 6.2176666834502088 double chf = gompertz.CumulativeHazardFunction(x: 0.27); // 1.4524242576820101 string str = gompertz.ToString(System.Globalization.CultureInfo.InvariantCulture); // "Gompertz(x; η = 4.2, b = 1.1)" Assert.AreEqual(0.13886469671401389, median); Assert.AreEqual(1.4524242576820101, chf); Assert.AreEqual(0.76599768199799145, cdf); Assert.AreEqual(1.4549484164912097, pdf); Assert.AreEqual(0.37497044741163688, lpdf); Assert.AreEqual(6.2176666834502088, hf); Assert.AreEqual(0.23400231800200855, ccdf); Assert.AreEqual(0.26999999999766749, icdf); Assert.AreEqual("Gompertz(x; η = 4.2, b = 1.1)", str); }
public void ConstructorTest() { var gompertz = new GompertzDistribution(eta: 4.2, b: 1.1); try { double mean = gompertz.Mean; Assert.Fail(); } catch { } double median = gompertz.Median; // 0.13886469671401389 double mode = gompertz.Mode; // 0.0 double cdf = gompertz.DistributionFunction(x: 0.27); // 0.76599768199799145 double pdf = gompertz.ProbabilityDensityFunction(x: 0.27); // 1.4549484164912097 double lpdf = gompertz.LogProbabilityDensityFunction(x: 0.27); // 0.37497044741163688 double ccdf = gompertz.ComplementaryDistributionFunction(x: 0.27); // 0.23400231800200855 double icdf = gompertz.InverseDistributionFunction(p: cdf); // 0.26999999999766749 double hf = gompertz.HazardFunction(x: 0.27); // 6.2176666834502088 double chf = gompertz.CumulativeHazardFunction(x: 0.27); // 1.4524242576820101 string str = gompertz.ToString(System.Globalization.CultureInfo.InvariantCulture); // "Gompertz(x; η = 4.2, b = 1.1)" Assert.AreEqual(0.13886469671401389, median); Assert.AreEqual(0.0, mode); Assert.AreEqual(1.4524242576820101, chf); Assert.AreEqual(0.76599768199799145, cdf); Assert.AreEqual(1.4549484164912097, pdf); Assert.AreEqual(0.37497044741163688, lpdf); Assert.AreEqual(6.2176666834502088, hf); Assert.AreEqual(0.23400231800200855, ccdf); Assert.AreEqual(0.26999999999766749, icdf); Assert.AreEqual("Gompertz(x; η = 4.2, b = 1.1)", str); var range1 = gompertz.GetRange(0.95); var range2 = gompertz.GetRange(0.99); var range3 = gompertz.GetRange(0.01); Assert.AreEqual(0.011035174219697141, range1.Min, 1e-6); Assert.AreEqual(0.48945776418276288, range1.Max, 1e-6); Assert.AreEqual(0.002172798720176344, range2.Min, 1e-6); Assert.AreEqual(0.67295877422837591, range2.Max, 1e-6); Assert.AreEqual(0.0021727987201762976, range3.Min, 1e-6); Assert.AreEqual(0.67295877422837591, range3.Max, 1e-6); }
public void ConstructorTest2() { var gompertz = new GompertzDistribution(eta: 0.2, b: 1.1); try { double mean = gompertz.Mean; Assert.Fail(); } catch { } double median = gompertz.Median; // 1.3603945605494754 double mode = gompertz.Mode; // 1.4631253749400912 double cdf = gompertz.DistributionFunction(x: 0.27); // 0.066825495660013834 double pdf = gompertz.ProbabilityDensityFunction(x: 0.27); // 0.27629371549904269 double lpdf = gompertz.LogProbabilityDensityFunction(x: 0.27); // -1.2862907925193949 double ccdf = gompertz.ComplementaryDistributionFunction(x: 0.27); // 0.93317450433998617 double icdf = gompertz.InverseDistributionFunction(p: cdf); // 0.27000016175969527 double hf = gompertz.HazardFunction(x: 0.27); // 0.29607936587858147 double chf = gompertz.CumulativeHazardFunction(x: 0.27); // 0.069163059889619516 string str = gompertz.ToString(System.Globalization.CultureInfo.InvariantCulture); // "Gompertz(x; η = 4.2, b = 1.1)" Assert.AreEqual(1.3603945605494754, median); Assert.AreEqual(1.4631253749400912, mode); Assert.AreEqual(0.069163059889619516, chf); Assert.AreEqual(0.066825495660013834, cdf); Assert.AreEqual(0.27629371549904269, pdf); Assert.AreEqual(-1.2862907925193949, lpdf); Assert.AreEqual(0.29607936587858147, hf); Assert.AreEqual(0.93317450433998617, ccdf); Assert.AreEqual(0.27000016175969527, icdf); Assert.AreEqual("Gompertz(x; η = 0.2, b = 1.1)", str); }
public void ConstructorTest13() { var original = new GompertzDistribution(eta: 4.2, b: 1.1); var gompertz = GeneralContinuousDistribution.FromDistributionFunction( original.Support, original.DistributionFunction); for (double i = -10; i < +10; i += 0.1) { double expected = original.DistributionFunction(i); double actual = gompertz.DistributionFunction(i); Assert.IsTrue(expected.IsRelativelyEqual(actual, 1e-7)); Assert.IsFalse(double.IsNaN(expected)); Assert.IsFalse(double.IsNaN(actual)); } testGompertz(gompertz); }
public void ConstructorTest12() { var original = new GompertzDistribution(eta: 4.2, b: 1.1); var gompertz = GeneralContinuousDistribution.FromDensityFunction( original.Support, original.ProbabilityDensityFunction); for (double i = -10; i < +7; i += 0.1) { double expected = original.DistributionFunction(i); double actual = gompertz.DistributionFunction(i); double diff = Math.Abs(expected - actual); Assert.AreEqual(expected, actual, 1e-3); Assert.IsFalse(double.IsNaN(expected)); Assert.IsFalse(double.IsNaN(actual)); } testGompertz(gompertz); }