public void ConstructorTest2() { var nakagami = new NakagamiDistribution(shape: 2.4, spread: 4.2); double mean = nakagami.Mean; // 1.946082119049118 double median = nakagami.Median; // 1.9061151110206338 double var = nakagami.Variance; // 0.41276438591729486 double cdf = nakagami.DistributionFunction(x: 1.4); // 0.20603416752368109 double pdf = nakagami.ProbabilityDensityFunction(x: 1.4); // 0.49253215371343023 double lpdf = nakagami.LogProbabilityDensityFunction(x: 1.4); // -0.708195533773302 double ccdf = nakagami.ComplementaryDistributionFunction(x: 1.4); // 0.79396583247631891 double icdf = nakagami.InverseDistributionFunction(p: cdf); // 1.400000000131993 double hf = nakagami.HazardFunction(x: 1.4); // 0.62034426869133652 double chf = nakagami.CumulativeHazardFunction(x: 1.4); // 0.23071485080660473 string str = nakagami.ToString(CultureInfo.InvariantCulture); // Nakagami(x; μ = 2,4, ω = 4,2)" Assert.AreEqual(1.946082119049118, mean); Assert.AreEqual(1.9061151110206338, median, 1e-6); Assert.AreEqual(0.41276438591729486, var); Assert.AreEqual(0.23071485080660473, chf); Assert.AreEqual(0.20603416752368109, cdf); Assert.AreEqual(0.49253215371343023, pdf); Assert.AreEqual(-0.708195533773302, lpdf); Assert.AreEqual(0.62034426869133652, hf); Assert.AreEqual(0.79396583247631891, ccdf); Assert.AreEqual(1.40, icdf, 1e-7); Assert.AreEqual("Nakagami(x; μ = 2.4, ω = 4.2)", str); }
public void ConstructorTest2() { var nakagami = new NakagamiDistribution(shape: 2.4, spread: 4.2); double mean = nakagami.Mean; // 1.946082119049118 double median = nakagami.Median; // 1.9061151110206338 double var = nakagami.Variance; // 0.41276438591729486 double mode = nakagami.Mode; // 1.8234582528810468 double cdf = nakagami.DistributionFunction(x: 1.4); // 0.20603416752368109 double pdf = nakagami.ProbabilityDensityFunction(x: 1.4); // 0.49253215371343023 double lpdf = nakagami.LogProbabilityDensityFunction(x: 1.4); // -0.708195533773302 double ccdf = nakagami.ComplementaryDistributionFunction(x: 1.4); // 0.79396583247631891 double icdf = nakagami.InverseDistributionFunction(p: cdf); // 1.400000000131993 double hf = nakagami.HazardFunction(x: 1.4); // 0.62034426869133652 double chf = nakagami.CumulativeHazardFunction(x: 1.4); // 0.23071485080660473 string str = nakagami.ToString(CultureInfo.InvariantCulture); // Nakagami(x; μ = 2,4, ω = 4,2)" Assert.AreEqual(1.946082119049118, mean); Assert.AreEqual(1.9061151110206338, median, 1e-6); Assert.AreEqual(1.8234582528810468, mode); Assert.AreEqual(0.41276438591729486, var); Assert.AreEqual(0.23071485080660473, chf); Assert.AreEqual(0.20603416752368109, cdf); Assert.AreEqual(0.49253215371343023, pdf); Assert.AreEqual(-0.708195533773302, lpdf); Assert.AreEqual(0.62034426869133652, hf); Assert.AreEqual(0.79396583247631891, ccdf); Assert.AreEqual(1.40, icdf, 1e-7); Assert.AreEqual("Nakagami(x; μ = 2.4, ω = 4.2)", str); var range1 = nakagami.GetRange(0.95); var range2 = nakagami.GetRange(0.99); var range3 = nakagami.GetRange(0.01); Assert.AreEqual(0.96015082529305074, range1.Min); Assert.AreEqual(3.0683231810919338, range1.Max); Assert.AreEqual(0.65984207711153242, range2.Min); Assert.AreEqual(3.5903316858157317, range2.Max); Assert.AreEqual(0.6598420771115322, range3.Min); Assert.AreEqual(3.5903316858157317, range3.Max); }