public void ConstructorTest() { // Create a new Anderson Darling distribution (A²) for comparing against a Gaussian var a2 = new AndersonDarlingDistribution(AndersonDarlingDistributionType.Normal, 30); double median = a2.Median; // 0.33089957635450062 double chf = a2.CumulativeHazardFunction(x: 0.27); // 0.42618068373640966 double cdf = a2.DistributionFunction(x: 0.27); // 0.34700165471995292 double ccdf = a2.ComplementaryDistributionFunction(x: 0.27); // 0.65299834528004708 double icdf = a2.InverseDistributionFunction(p: cdf); // 0.27000000012207787 string str = a2.ToString(CultureInfo.InvariantCulture); // "A²(x; n = 30)" Assert.AreEqual(0.33089957635450062, median); Assert.AreEqual(0.42618068373640966, chf); Assert.AreEqual(0.34700165471995292, cdf); Assert.AreEqual(0.65299834528004708, ccdf); Assert.AreEqual(0.27, icdf, 1e-6); Assert.AreEqual("A²(x; n = 30)", str); Assert.IsFalse(Double.IsNaN(median)); var range1 = a2.GetRange(0.95); var range2 = a2.GetRange(0.99); var range3 = a2.GetRange(0.01); Assert.AreEqual(0.1552371857564955, range1.Min); Assert.AreEqual(0.73303544269106991, range1.Max); Assert.AreEqual(0.11507415861447158, range2.Min); Assert.AreEqual(1.0, range2.Max); Assert.AreEqual(0.1150741586144715, range3.Min); Assert.AreEqual(1.0, range3.Max); }
public void uniform_test() { // Create a new Anderson Darling distribution (A²) for comparing against a Uniform distribution var a2 = new AndersonDarlingDistribution(AndersonDarlingDistributionType.Uniform, 10); double median = a2.Median; double chf = a2.CumulativeHazardFunction(x: 0.27); double cdf = a2.DistributionFunction(x: 0.27); double ccdf = a2.ComplementaryDistributionFunction(x: 0.27); double icdf = a2.InverseDistributionFunction(p: cdf); string str = a2.ToString(CultureInfo.InvariantCulture); // "A²(x; n = 30)" Assert.AreEqual(0.76936270639003257, median, 1e-6); Assert.AreEqual(0.0424239540571123, chf, 1e-6); Assert.AreEqual(0.041536650001198654, cdf, 1e-6); Assert.AreEqual(0.95846334999880134, ccdf, 1e-6); Assert.AreEqual(0.27, icdf, 1e-6); Assert.AreEqual("A²(x; n = 10)", str); Assert.IsFalse(Double.IsNaN(median)); var range1 = a2.GetRange(0.95); var range2 = a2.GetRange(0.99); var range3 = a2.GetRange(0.01); Assert.AreEqual(0.28254198132705227, range1.Min, 1e-6); Assert.AreEqual(2.5127111321231137, range1.Max, 1e-6); Assert.AreEqual(0.20232764997988909, range2.Min, 1e-6); Assert.AreEqual(3.9195747018635374, range2.Max, 1e-6); Assert.AreEqual(0.20232764997988903, range3.Min, 1e-6); Assert.AreEqual(3.9195747018635374, range3.Max, 1e-6); Assert.AreEqual(0, a2.Support.Min); Assert.AreEqual(Double.PositiveInfinity, a2.Support.Max); Assert.AreEqual(a2.InverseDistributionFunction(0), a2.Support.Min); Assert.AreEqual(a2.InverseDistributionFunction(1), a2.Support.Max); }