public void CauchyDistributionConstructorTest2() { double location = 0.42; double scale = 1.57; CauchyDistribution cauchy = new CauchyDistribution(location, scale); double mean = cauchy.Mean; // NaN - Cauchy's mean is undefined. double var = cauchy.Variance; // NaN - Cauchy's variance is undefined. double median = cauchy.Median; // 0.42 double cdf = cauchy.DistributionFunction(x: 0.27); // 0.46968025841608563 double pdf = cauchy.ProbabilityDensityFunction(x: 0.27); // 0.2009112009763413 double lpdf = cauchy.LogProbabilityDensityFunction(x: 0.27); // -1.6048922547266871 double ccdf = cauchy.ComplementaryDistributionFunction(x: 0.27); // 0.53031974158391437 double icdf = cauchy.InverseDistributionFunction(p: 0.69358638272337991); // 1.5130304686978195 double hf = cauchy.HazardFunction(x: 0.27); // 0.3788491832800277 double chf = cauchy.CumulativeHazardFunction(x: 0.27); // 0.63427516833243092 string str = cauchy.ToString(System.Globalization.CultureInfo.InvariantCulture); // "Cauchy(x; x0 = 0.42, γ = 1.57) Assert.IsTrue(Double.IsNaN(mean)); Assert.IsTrue(Double.IsNaN(var)); Assert.AreEqual(0.42, median); Assert.AreEqual(0.63427516833243092, chf); Assert.AreEqual(0.46968025841608563, cdf); Assert.AreEqual(0.2009112009763413, pdf); Assert.AreEqual(-1.6048922547266871, lpdf); Assert.AreEqual(0.3788491832800277, hf); Assert.AreEqual(0.53031974158391437, ccdf); Assert.AreEqual(1.5130304686978195, icdf); Assert.AreEqual("Cauchy(x; x0 = 0.42, γ = 1.57)", str); }
public void CauchyDistributionConstructorTest2() { double location = 0.42; double scale = 1.57; CauchyDistribution cauchy = new CauchyDistribution(location, scale); double mean = cauchy.Mean; // NaN - Cauchy's mean is undefined. double var = cauchy.Variance; // NaN - Cauchy's variance is undefined. double median = cauchy.Median; // 0.42 double mode = cauchy.Mode; // 0.42 double cdf = cauchy.DistributionFunction(x: 0.27); // 0.46968025841608563 double pdf = cauchy.ProbabilityDensityFunction(x: 0.27); // 0.2009112009763413 double lpdf = cauchy.LogProbabilityDensityFunction(x: 0.27); // -1.6048922547266871 double ccdf = cauchy.ComplementaryDistributionFunction(x: 0.27); // 0.53031974158391437 double icdf = cauchy.InverseDistributionFunction(p: 0.69358638272337991); // 1.5130304686978195 double hf = cauchy.HazardFunction(x: 0.27); // 0.3788491832800277 double chf = cauchy.CumulativeHazardFunction(x: 0.27); // 0.63427516833243092 string str = cauchy.ToString(System.Globalization.CultureInfo.InvariantCulture); // "Cauchy(x; x0 = 0.42, γ = 1.57) Assert.IsTrue(Double.IsNaN(mean)); Assert.IsTrue(Double.IsNaN(var)); Assert.AreEqual(0.42, median); Assert.AreEqual(0.42, mode, 1e-6); Assert.AreEqual(0.63427516833243092, chf); Assert.AreEqual(0.46968025841608563, cdf); Assert.AreEqual(0.2009112009763413, pdf); Assert.AreEqual(-1.6048922547266871, lpdf); Assert.AreEqual(0.3788491832800277, hf); Assert.AreEqual(0.53031974158391437, ccdf); Assert.AreEqual(1.5130304686978195, icdf); Assert.AreEqual("Cauchy(x; x0 = 0.42, γ = 1.57)", str); var range1 = cauchy.GetRange(0.95); var range2 = cauchy.GetRange(0.99); var range3 = cauchy.GetRange(0.01); Assert.AreEqual(-9.4925897567183526, range1.Min, 1e-10); Assert.AreEqual(10.332589895085842, range1.Max, 1e-10); Assert.AreEqual(-49.538210069999685, range2.Min, 1e-10); Assert.AreEqual(50.378210075966564, range2.Max, 1e-10); Assert.AreEqual(-49.538210069999892, range3.Min, 1e-10); Assert.AreEqual(50.378210075966564, range3.Max, 1e-10); Assert.AreEqual(Double.NegativeInfinity, cauchy.Support.Min); Assert.AreEqual(Double.PositiveInfinity, cauchy.Support.Max); Assert.AreEqual(cauchy.InverseDistributionFunction(0), cauchy.Support.Min); Assert.AreEqual(cauchy.InverseDistributionFunction(1), cauchy.Support.Max); }