From c8094b86da882298a87d462f16cd1c22c574aa2d Mon Sep 17 00:00:00 2001 From: "Paul A. Bristow" Date: Wed, 3 Jan 2007 17:38:38 +0000 Subject: [PATCH] Coected test sof kurtosis (and k neither 0 or 1) [SVN r3595] --- test/test_bernoulli.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/test/test_bernoulli.cpp b/test/test_bernoulli.cpp index b3ca3ab68..d2342a246 100644 --- a/test/test_bernoulli.cpp +++ b/test/test_bernoulli.cpp @@ -45,7 +45,7 @@ template // Any floating-point type RealType. void test_spots(RealType) { // Parameter only provides the type, float, double... value ignored. - // Basic sanity checks, test data is to double precision only + // Basic sanity checks, test data may be to double precision only // so set tolerance to 100 eps expressed as a fraction, // or 100 eps of type double expressed as a fraction, // whichever is the larger. @@ -58,7 +58,9 @@ void test_spots(RealType) cout << "Tolerance for type " << typeid(RealType).name() << " is " << setprecision(3) << tolerance << " (or " << tolerance * 100 << "%)." << endl; - // Sources of spot test values: + // Sources of spot test values - calculator, + // or Steve Moshier's command interpreter V1.3 100 decimal digit calculator, + // Wolfram function evaluator. using boost::math::bernoulli_distribution; // of type RealType. using ::boost::math::cdf; @@ -120,13 +122,18 @@ void test_spots(RealType) BOOST_CHECK_CLOSE_FRACTION( kurtosis(bernoulli_distribution(static_cast(0.1L))), + static_cast(8.11111111111111111111111111111111111111111111L), + tolerance); + + BOOST_CHECK_CLOSE_FRACTION( + kurtosis_excess(bernoulli_distribution(static_cast(0.1L))), static_cast(5.11111111111111111111111111111111111111111111L), tolerance); + // median NOT implemented. BOOST_CHECK_THROW( median(bernoulli_distribution(static_cast(0.5L))), std::domain_error); - BOOST_CHECK_THROW( quantile( bernoulli_distribution(static_cast(2)), // prob >1 @@ -223,20 +230,17 @@ int test_main(int, char* []) BOOST_CHECK_THROW(bernoulli_distribution bn3(std::numeric_limits::quiet_NaN() ), std::domain_error); // p outside 0 to 1. BOOST_CHECK_THROW(bernoulli_distribution bn4(std::numeric_limits::infinity() ), std::domain_error); // p outside 0 to 1. - BOOST_CHECK_EQUAL(kurtosis(bn2) -3, kurtosis_excess(bn2)); - BOOST_CHECK_EQUAL(kurtosis(bn2), -2); - BOOST_CHECK_EQUAL(kurtosis_excess(bn2), -5); - BOOST_CHECK_EQUAL(kurtosis_excess(bn2), -5); + BOOST_CHECK_EQUAL(kurtosis_excess(bn2), -2); //using namespace boost::math; or using boost::math::bernoulli; double tol5eps = std::numeric_limits::epsilon() * 5; // 5 eps as a fraction. - BOOST_CHECK_CLOSE_FRACTION(kurtosis_excess(bernoulli(0.1)), 2.11111111111111111111111111111111111111111111111111, tol5eps); - BOOST_CHECK_CLOSE_FRACTION(kurtosis_excess(bernoulli(0.9)), 2.11111111111111111111111111111111111111111111111111, tol5eps); - BOOST_CHECK_CLOSE_FRACTION(kurtosis(bernoulli(0.6)), -1.8333333333333333333333333333333333333333333333333, tol5eps); + BOOST_CHECK_CLOSE_FRACTION(kurtosis_excess(bernoulli(0.1)), 5.11111111111111111111111111111111111111111111111111, tol5eps); + BOOST_CHECK_CLOSE_FRACTION(kurtosis_excess(bernoulli(0.9)), 5.11111111111111111111111111111111111111111111111111, tol5eps); + BOOST_CHECK_CLOSE_FRACTION(kurtosis(bernoulli(0.6)), 1/0.4 + 1/0.6 -3, tol5eps); BOOST_CHECK_EQUAL(kurtosis(bernoulli(0)), +std::numeric_limits::infinity()); BOOST_CHECK_EQUAL(kurtosis(bernoulli(1)), +std::numeric_limits::infinity()); // @@ -274,8 +278,6 @@ Tolerance for type double is 2.22e-014 (or 2.22e-012%). Tolerance for type long double is 2.22e-014 (or 2.22e-012%). Tolerance for type class boost::math::concepts::real_concept is 2.22e-014 (or 2.22e-012%). *** No errors detected -Build Time 0:05 - */ \ No newline at end of file