From 7d8c38d18a82468058851b2de8a9dcb9921fd422 Mon Sep 17 00:00:00 2001 From: Heiko Strathmann Date: Sun, 27 Mar 2016 19:12:25 +0100 Subject: [PATCH] fix gamma_cdf unit tests --- tests/unit/mathematics/Statistics_unittest.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/unit/mathematics/Statistics_unittest.cc b/tests/unit/mathematics/Statistics_unittest.cc index 7732af7935a..d4b8793b972 100644 --- a/tests/unit/mathematics/Statistics_unittest.cc +++ b/tests/unit/mathematics/Statistics_unittest.cc @@ -617,27 +617,26 @@ TEST(Statistics, gamma_cdf) // incomplete gamma is based on is tested thoroughly already result=CStatistics::gamma_cdf(2, 1, 1); EXPECT_NEAR(result, 0.8646647167633873, 1e-15); + result=CStatistics::gamma_cdf(2, 2, 1); EXPECT_NEAR(result, 0.59399415029016167, 1e-15); + result=CStatistics::gamma_cdf(2, 1, 2); EXPECT_NEAR(result, 0.98168436111126578, 1e-15); } -TEST(Statistics, chi2_pdf) -{ - EXPECT_NEAR(0, 1, 1e-15); -} - TEST(Statistics, chi2_cdf) { - float64_t chi2c=CStatistics::chi2_cdf(1.0, 5.0); - EXPECT_NEAR(chi2c, 0.03743423, 1e-7); + // tests against scipy.stats.chi2.cdf + // few tests since gamma_incomplete_lower is already thoroughly tested + float64_t chi2c=CStatistics::chi2_cdf(1, 1); + EXPECT_NEAR(chi2c, 0.68268949213708596, 1e-15); chi2c=CStatistics::chi2_cdf(10.0, 5.0); - EXPECT_NEAR(chi2c, 0.92476475, 1e-7); + EXPECT_NEAR(chi2c, 0.92476475385348778, 1e-15); chi2c=CStatistics::chi2_cdf(1.0, 15.0); - EXPECT_NEAR(chi2c, 0.00000025, 1e-7); + EXPECT_NEAR(chi2c, 2.5356443108232581e-07, 1e-15); } TEST(Statistics, fdistribution_cdf)