public DistributionFunction ( double x ) : double | ||
x | double | A single point in the distribution range. |
리턴 | double |
public void ConstructorTest1() { var log = new LogisticDistribution(location: 0.42, scale: 1.2); double mean = log.Mean; // 0.42 double median = log.Median; // 0.42 double mode = log.Mode; // 0.42 double var = log.Variance; // 4.737410112522892 double cdf = log.DistributionFunction(x: 1.4); // 0.693528308197921 double pdf = log.ProbabilityDensityFunction(x: 1.4); // 0.17712232827170876 double lpdf = log.LogProbabilityDensityFunction(x: 1.4); // -1.7309146649427332 double ccdf = log.ComplementaryDistributionFunction(x: 1.4); // 0.306471691802079 double icdf = log.InverseDistributionFunction(p: cdf); // 1.3999999999999997 double hf = log.HazardFunction(x: 1.4); // 0.57794025683160088 double chf = log.CumulativeHazardFunction(x: 1.4); // 1.1826298874077226 string str = log.ToString(CultureInfo.InvariantCulture); // Logistic(x; μ = 0.42, scale = 1.2) Assert.AreEqual(0.41999999999999998, mean); Assert.AreEqual(0.41999999999999998, median); Assert.AreEqual(4.737410112522892, var); Assert.AreEqual(1.1826298874077226, chf); Assert.AreEqual(0.693528308197921, cdf); Assert.AreEqual(0.17712232827170876, pdf); Assert.AreEqual(-1.7309146649427332, lpdf); Assert.AreEqual(0.57794025683160088, hf); Assert.AreEqual(0.306471691802079, ccdf); Assert.AreEqual(1.3999999999999997, icdf); Assert.AreEqual("Logistic(x; μ = 0.42, scale = 1.2)", str); }
public void EquivalencyTest3() { // when ksi -> 0, the shifted log-logistic reduces to the logistic distribution. double sigma = 0.42; // scale double ksi = 0; // shape double mu = 2.4; // location var target = new ShiftedLogLogisticDistribution(location: mu, scale: sigma, shape: ksi); var log = new LogisticDistribution(mu, sigma); Assert.AreEqual(log.Mean, target.Mean); Assert.AreEqual(log.Median, target.Median); Assert.AreEqual(log.Mode, target.Mode); Assert.AreEqual(log.Variance, target.Variance); double actual, expected; for (double i = -10; i < 10; i += 0.1) { expected = log.DistributionFunction(i); actual = target.DistributionFunction(i); Assert.IsTrue(expected.IsRelativelyEqual(actual, 1e-15)); expected = log.ProbabilityDensityFunction(i); actual = target.ProbabilityDensityFunction(i); Assert.IsTrue(expected.IsRelativelyEqual(actual, 1e-15)); expected = log.LogProbabilityDensityFunction(i); actual = target.LogProbabilityDensityFunction(i); Assert.IsTrue(expected.IsRelativelyEqual(actual, 1e-10)); expected = log.ComplementaryDistributionFunction(i); actual = target.ComplementaryDistributionFunction(i); Assert.IsTrue(expected.IsRelativelyEqual(actual, 1e-15)); double p = log.DistributionFunction(i); expected = log.InverseDistributionFunction(p); actual = target.InverseDistributionFunction(p); Assert.AreEqual(expected, actual, 1e-5); expected = log.HazardFunction(i); actual = target.HazardFunction(i); Assert.IsTrue(expected.IsRelativelyEqual(actual, 1e-15)); expected = log.CumulativeHazardFunction(i); actual = target.CumulativeHazardFunction(i); Assert.IsTrue(expected.IsRelativelyEqual(actual, 1e-15)); } }