for(unsigned i = 0; i < binomial_quantile_data.size(); ++i)
{
using namespace boost::math::policies;
- typedef policy<discrete_quantile<boost::math::policies::real> > P1;
- typedef policy<discrete_quantile<integer_round_down> > P2;
- typedef policy<discrete_quantile<integer_round_up> > P3;
- typedef policy<discrete_quantile<integer_round_outwards> > P4;
- typedef policy<discrete_quantile<integer_round_inwards> > P5;
- typedef policy<discrete_quantile<integer_round_nearest> > P6;
RealType tol = boost::math::tools::epsilon<RealType>() * 500;
if(!boost::is_floating_point<RealType>::value)
tol *= 10; // no lanczos approximation implies less accuracy
//
// Check full real value first:
//
+ typedef policy<discrete_quantile<boost::math::policies::real> > P1;
binomial_distribution<RealType, P1> p1(binomial_quantile_data[i][0], binomial_quantile_data[i][1]);
x = quantile(p1, binomial_quantile_data[i][2]);
BOOST_CHECK_CLOSE_FRACTION(x, (RealType)binomial_quantile_data[i][3], tol);
//
// Now with round down to integer:
//
+ typedef policy<discrete_quantile<integer_round_down> > P2;
binomial_distribution<RealType, P2> p2(binomial_quantile_data[i][0], binomial_quantile_data[i][1]);
x = quantile(p2, binomial_quantile_data[i][2]);
BOOST_CHECK_EQUAL(x, (RealType)floor(binomial_quantile_data[i][3]));
//
// Now with round up to integer:
//
+ typedef policy<discrete_quantile<integer_round_up> > P3;
binomial_distribution<RealType, P3> p3(binomial_quantile_data[i][0], binomial_quantile_data[i][1]);
x = quantile(p3, binomial_quantile_data[i][2]);
BOOST_CHECK_EQUAL(x, (RealType)ceil(binomial_quantile_data[i][3]));
//
// Now with round to integer "outside":
//
+ typedef policy<discrete_quantile<integer_round_outwards> > P4;
binomial_distribution<RealType, P4> p4(binomial_quantile_data[i][0], binomial_quantile_data[i][1]);
x = quantile(p4, binomial_quantile_data[i][2]);
BOOST_CHECK_EQUAL(x, (RealType)(binomial_quantile_data[i][2] < 0.5f ? floor(binomial_quantile_data[i][3]) : ceil(binomial_quantile_data[i][3])));
//
// Now with round to integer "inside":
//
+ typedef policy<discrete_quantile<integer_round_inwards> > P5;
binomial_distribution<RealType, P5> p5(binomial_quantile_data[i][0], binomial_quantile_data[i][1]);
x = quantile(p5, binomial_quantile_data[i][2]);
BOOST_CHECK_EQUAL(x, (RealType)(binomial_quantile_data[i][2] < 0.5f ? ceil(binomial_quantile_data[i][3]) : floor(binomial_quantile_data[i][3])));
//
// Now with round to nearest integer:
//
+ typedef policy<discrete_quantile<integer_round_nearest> > P6;
binomial_distribution<RealType, P6> p6(binomial_quantile_data[i][0], binomial_quantile_data[i][1]);
x = quantile(p6, binomial_quantile_data[i][2]);
BOOST_CHECK_EQUAL(x, (RealType)(floor(binomial_quantile_data[i][3] + 0.5f)));
Tolerance for type double is 2.22045e-011 %
Tolerance for type long double is 2.22045e-011 %
Tolerance for type class boost::math::concepts::real_concept is 2.22045e-011 %
-
+
*** No errors detected
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========