1 // (C) Copyright Eric Niebler 2005.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 // Test case for extended_p_square_quantile.hpp
9 #include <boost/random.hpp>
10 #include <boost/test/unit_test.hpp>
11 #include <boost/test/floating_point_comparison.hpp>
12 #include <boost/accumulators/numeric/functional/vector.hpp>
13 #include <boost/accumulators/numeric/functional/complex.hpp>
14 #include <boost/accumulators/numeric/functional/valarray.hpp>
15 #include <boost/accumulators/accumulators.hpp>
16 #include <boost/accumulators/statistics/stats.hpp>
17 #include <boost/accumulators/statistics/extended_p_square_quantile.hpp>
19 using namespace boost
;
20 using namespace unit_test
;
21 using namespace boost::accumulators
;
23 ///////////////////////////////////////////////////////////////////////////////
28 typedef accumulator_set
<double, stats
<tag::extended_p_square_quantile
> > accumulator_t
;
29 typedef accumulator_set
<double, stats
<tag::weighted_extended_p_square_quantile
>, double > accumulator_t_weighted
;
30 typedef accumulator_set
<double, stats
<tag::extended_p_square_quantile(quadratic
)> > accumulator_t_quadratic
;
31 typedef accumulator_set
<double, stats
<tag::weighted_extended_p_square_quantile(quadratic
)>, double > accumulator_t_weighted_quadratic
;
36 // a random number generator
37 boost::lagged_fibonacci607 rng
;
39 std::vector
<double> probs
;
41 probs
.push_back(0.990);
42 probs
.push_back(0.991);
43 probs
.push_back(0.992);
44 probs
.push_back(0.993);
45 probs
.push_back(0.994);
46 probs
.push_back(0.995);
47 probs
.push_back(0.996);
48 probs
.push_back(0.997);
49 probs
.push_back(0.998);
50 probs
.push_back(0.999);
52 accumulator_t
acc(extended_p_square_probabilities
= probs
);
53 accumulator_t_weighted
acc_weighted(extended_p_square_probabilities
= probs
);
54 accumulator_t_quadratic
acc2(extended_p_square_probabilities
= probs
);
55 accumulator_t_weighted_quadratic
acc_weighted2(extended_p_square_probabilities
= probs
);
57 for (int i
=0; i
<10000; ++i
)
59 double sample
= rng();
62 acc_weighted(sample
, weight
= 1.);
63 acc_weighted2(sample
, weight
= 1.);
66 for (std::size_t i
= 0; i
< probs
.size() - 1; ++i
)
69 quantile(acc
, quantile_probability
= 0.99025 + i
*0.001)
74 quantile(acc2
, quantile_probability
= 0.99025 + i
*0.001)
79 quantile(acc_weighted
, quantile_probability
= 0.99025 + i
*0.001)
84 quantile(acc_weighted2
, quantile_probability
= 0.99025 + i
*0.001)
91 ///////////////////////////////////////////////////////////////////////////////
92 // init_unit_test_suite
94 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
96 test_suite
*test
= BOOST_TEST_SUITE("extended_p_square_quantile test");
98 test
->add(BOOST_TEST_CASE(&test_stat
));