public void ConstructorTest() { var log = new LognormalDistribution(location: 0.42, shape: 1.1); double mean = log.Mean; // 2.7870954605658511 double median = log.Median; // 1.5219615583481305 double var = log.Variance; // 18.28163603621158 double cdf = log.DistributionFunction(x: 0.27); // 0.057961222885664958 double pdf = log.ProbabilityDensityFunction(x: 0.27); // 0.39035530085982068 double lpdf = log.LogProbabilityDensityFunction(x: 0.27); // -0.94069792674674835 double ccdf = log.ComplementaryDistributionFunction(x: 0.27); // 0.942038777114335 double icdf = log.InverseDistributionFunction(p: cdf); // 0.26999997937815973 double hf = log.HazardFunction(x: 0.27); // 0.41437285846720867 double chf = log.CumulativeHazardFunction(x: 0.27); // 0.059708840588116374 string str = log.ToString("N2", CultureInfo.InvariantCulture); // Lognormal(x; μ = 2.79, σ = 1.10) Assert.AreEqual(2.7870954605658511, mean); Assert.AreEqual(1.5219615583481305, median, 1e-7); Assert.AreEqual(18.28163603621158, var); Assert.AreEqual(0.059708840588116374, chf); Assert.AreEqual(0.057961222885664958, cdf); Assert.AreEqual(0.39035530085982068, pdf); Assert.AreEqual(-0.94069792674674835, lpdf); Assert.AreEqual(0.41437285846720867, hf); Assert.AreEqual(0.942038777114335, ccdf); Assert.AreEqual(0.26999997937815973, icdf, 1e-7); Assert.AreEqual("Lognormal(x; μ = 2.79, σ = 1.10)", str); }
public void ConstructorTest() { var log = new LognormalDistribution(location: 0.42, shape: 1.1); double mean = log.Mean; // 2.7870954605658511 double median = log.Median; // 1.5219615583481305 double var = log.Variance; // 18.28163603621158 double mode = log.Mode; // 0.45384479528235572 double cdf = log.DistributionFunction(x: 0.27); // 0.057961222885664958 double pdf = log.ProbabilityDensityFunction(x: 0.27); // 0.39035530085982068 double lpdf = log.LogProbabilityDensityFunction(x: 0.27); // -0.94069792674674835 double ccdf = log.ComplementaryDistributionFunction(x: 0.27); // 0.942038777114335 double icdf = log.InverseDistributionFunction(p: cdf); // 0.26999997937815973 double hf = log.HazardFunction(x: 0.27); // 0.41437285846720867 double chf = log.CumulativeHazardFunction(x: 0.27); // 0.059708840588116374 string str = log.ToString("N2", CultureInfo.InvariantCulture); // Lognormal(x; μ = 2.79, σ = 1.10) Assert.AreEqual(2.7870954605658511, mean); Assert.AreEqual(1.5219615583481305, median, 1e-7); Assert.AreEqual(0.45384479528235572, mode); Assert.AreEqual(18.28163603621158, var); Assert.AreEqual(0.059708840588116374, chf); Assert.AreEqual(0.057961222885664958, cdf); Assert.AreEqual(0.39035530085982068, pdf); Assert.AreEqual(-0.94069792674674835, lpdf); Assert.AreEqual(0.41437285846720867, hf); Assert.AreEqual(0.942038777114335, ccdf); Assert.AreEqual(0.26999997937815973, icdf, 1e-6); Assert.AreEqual("Lognormal(x; μ = 2.79, σ = 1.10)", str); var range1 = log.GetRange(0.95); Assert.AreEqual(0.24923999017902393, range1.Min); Assert.AreEqual(9.293720885640818, range1.Max); var range2 = log.GetRange(0.99); Assert.AreEqual(0.11777446636476178, range2.Min); Assert.AreEqual(19.667797655030668, range2.Max); var range3 = log.GetRange(0.01); Assert.AreEqual(0.11777446636476173, range3.Min); Assert.AreEqual(19.667797655030668, range3.Max); Assert.AreEqual(0, log.Support.Min); Assert.AreEqual(double.PositiveInfinity, log.Support.Max); Assert.AreEqual(log.InverseDistributionFunction(0), log.Support.Min); Assert.AreEqual(log.InverseDistributionFunction(1), log.Support.Max); }
public void ConstructorTest() { var log = new LognormalDistribution(location: 0.42, shape: 1.1); double mean = log.Mean; // 2.7870954605658511 double median = log.Median; // 1.5219615583481305 double var = log.Variance; // 18.28163603621158 double mode = log.Mode; // 0.45384479528235572 double cdf = log.DistributionFunction(x: 0.27); // 0.057961222885664958 double pdf = log.ProbabilityDensityFunction(x: 0.27); // 0.39035530085982068 double lpdf = log.LogProbabilityDensityFunction(x: 0.27); // -0.94069792674674835 double ccdf = log.ComplementaryDistributionFunction(x: 0.27); // 0.942038777114335 double icdf = log.InverseDistributionFunction(p: cdf); // 0.26999997937815973 double hf = log.HazardFunction(x: 0.27); // 0.41437285846720867 double chf = log.CumulativeHazardFunction(x: 0.27); // 0.059708840588116374 string str = log.ToString("N2", CultureInfo.InvariantCulture); // Lognormal(x; μ = 2.79, σ = 1.10) Assert.AreEqual(2.7870954605658511, mean); Assert.AreEqual(1.5219615583481305, median, 1e-7); Assert.AreEqual(0.45384479528235572, mode); Assert.AreEqual(18.28163603621158, var); Assert.AreEqual(0.059708840588116374, chf); Assert.AreEqual(0.057961222885664958, cdf); Assert.AreEqual(0.39035530085982068, pdf); Assert.AreEqual(-0.94069792674674835, lpdf); Assert.AreEqual(0.41437285846720867, hf); Assert.AreEqual(0.942038777114335, ccdf); Assert.AreEqual(0.26999997937815973, icdf, 1e-6); Assert.AreEqual("Lognormal(x; μ = 2.79, σ = 1.10)", str); var range1 = log.GetRange(0.95); Assert.AreEqual(0.24923999017902393, range1.Min); Assert.AreEqual(9.293720885640818, range1.Max); var range2 = log.GetRange(0.99); Assert.AreEqual(0.11777446636476178, range2.Min); Assert.AreEqual(19.667797655030668, range2.Max); var range3 = log.GetRange(0.01); Assert.AreEqual(0.11777446636476173, range3.Min); Assert.AreEqual(19.667797655030668, range3.Max); }