public void ConstructorTest() { var dist = new WrappedCauchyDistribution(mu: 0.42, gamma: 3); double mean = dist.Mean; // 0.42 double var = dist.Variance; // 0.950212931632136 try { double median = dist.Median; Assert.Fail(); } catch { } try { double mode = dist.Mode; Assert.Fail(); } catch { } double pdf = dist.ProbabilityDensityFunction(x: 0.42); // 0.1758330112785475 double lpdf = dist.LogProbabilityDensityFunction(x: 0.42); // -1.7382205338929015 string str = dist.ToString(CultureInfo.InvariantCulture); // "WrappedCauchy(x; μ = 0.42, γ = 3)" Assert.AreEqual(0.42, mean); Assert.AreEqual(0.950212931632136, var); Assert.AreEqual(0.1758330112785475, pdf, 1e-10); Assert.AreEqual(-1.7382205338929015, lpdf, 1e-10); Assert.AreEqual("WrappedCauchy(x; μ = 0.42, γ = 3)", str); Assert.IsFalse(Double.IsNaN(pdf)); Assert.IsFalse(Double.IsNaN(lpdf)); bool thrown = false; try { dist.GetRange(0.95); } catch (NotSupportedException) { thrown = true; } Assert.IsTrue(thrown); }
public void ConstructorTest() { var dist = new WrappedCauchyDistribution(mu: 0.42, gamma: 3); double mean = dist.Mean; // 0.42 double var = dist.Variance; // 0.950212931632136 double pdf = dist.ProbabilityDensityFunction(x: 0.42); // 0.1758330112785475 double lpdf = dist.LogProbabilityDensityFunction(x: 0.42); // -1.7382205338929015 string str = dist.ToString(CultureInfo.InvariantCulture); // "WrappedCauchy(x; μ = 0.42, γ = 3)" Assert.AreEqual(0.42, mean); Assert.AreEqual(0.950212931632136, var); Assert.AreEqual(0.1758330112785475, pdf); Assert.AreEqual(-1.7382205338929015, lpdf); Assert.AreEqual("WrappedCauchy(x; μ = 0.42, γ = 3)", str); }