public void ValidateDensity(double dof, double x, double expected) { var chi = new Chi(dof); Assert.That(chi.Density(x), Is.EqualTo(expected).Within(13)); Assert.That(Chi.PDF(dof, x), Is.EqualTo(expected).Within(13)); }
public void ValidateDensity(double dof, double x) { var n = new Chi(dof); double expected = (Math.Pow(2.0, 1.0 - (dof / 2.0)) * Math.Pow(x, dof - 1.0) * Math.Exp(-x * (x / 2.0))) / SpecialFunctions.Gamma(dof / 2.0); Assert.AreEqual(expected, n.Density(x)); Assert.AreEqual(expected, Chi.PDF(dof, x)); }