2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

more tests added to test new pdf and cdf code changes.

[SVN r3255]
This commit is contained in:
Paul A. Bristow
2006-10-15 15:39:14 +00:00
parent a9cfe8beec
commit fa33ecb003

View File

@@ -87,12 +87,40 @@ void test_spots(RealType)
using ::boost::math::cdf;
using ::boost::math::pdf;
BOOST_CHECK_CLOSE(
cdf(poisson_distribution<RealType>(static_cast<RealType>(0)), // mean zero
static_cast<RealType>(0)), // zero k events.
static_cast<RealType>(0), // probability zero.
tolerance);
BOOST_CHECK_CLOSE(
cdf(poisson_distribution<RealType>(static_cast<RealType>(0)), // mean zero
static_cast<RealType>(999)), // any k events.
static_cast<RealType>(0), // probability zero.
tolerance);
BOOST_CHECK_CLOSE(
cdf(poisson_distribution<RealType>(static_cast<RealType>(1)), // mean unity.
static_cast<RealType>(0)), // zero k events.
static_cast<RealType>(3.678794411714420E-1), // probability.
tolerance);
BOOST_CHECK_CLOSE(
cdf(poisson_distribution<RealType>(static_cast<RealType>(1)), // mean unity.
static_cast<RealType>(1)), // one k event.
static_cast<RealType>(7.357588823428830E-1), // probability.
tolerance);
BOOST_CHECK_CLOSE(
cdf(poisson_distribution<RealType>(static_cast<RealType>(1)), // mean unity.
static_cast<RealType>(2)), // two k events.
static_cast<RealType>(9.196986029286060E-1), // probability.
tolerance);
BOOST_CHECK_CLOSE(
cdf(poisson_distribution<RealType>(static_cast<RealType>(5.)), // mean
static_cast<RealType>(5)), // k events.
static_cast<RealType>(0.615960654833065), // probability.
tolerance);
BOOST_CHECK_CLOSE(
cdf(poisson_distribution<RealType>(static_cast<RealType>(5.)), // mean
static_cast<RealType>(1)), // k events.
@@ -172,8 +200,7 @@ int test_main(int, char* [])
cout << "BOOST_MATH_THROW_ON_DOMAIN_ERROR" << " is NOT defined, so NO throw on domain error." << endl;
#endif
#if 0
using boost::math::cdf;
using boost::math::pdf;
@@ -193,17 +220,12 @@ int test_main(int, char* [])
cout << p << ' '
<< sum <<' '
<< cdf(poisson_distribution<double>(mean), static_cast<double>(i)) << ' ';
if (i > 0)
{
cout << boost::math::gamma_Q<double>(i+1, mean);
double diff = boost::math::gamma_Q<double>(i+1, mean) - sum;
cout << ' ' << diff; // 0 0 to 4, 1 eps 5 to 9, 10 to 20 2 eps, 21 upwards 3 eps
}
else
{
cout << pdf(poisson_distribution<double>(mean), static_cast<double>(0));
}
cout << endl;
}
cout << cdf(poisson_distribution<double>(5), static_cast<double>(0)) << ' ' << endl; // 0.006737946999085467