1 | #include "gtest/gtest.h"
|
---|
2 | #include <memory>
|
---|
3 |
|
---|
4 | #include <array>
|
---|
5 | #include "boost/array.hpp"
|
---|
6 | #include "boost/accumulators/accumulators.hpp"
|
---|
7 | #include "boost/accumulators/statistics.hpp"
|
---|
8 | #include "boost/accumulators/statistics/p_square_quantile.hpp"
|
---|
9 | #include "boost/accumulators/statistics/extended_p_square.hpp"
|
---|
10 | using namespace boost::accumulators;
|
---|
11 |
|
---|
12 | TEST(Accumulator, ExtendedPSquare)
|
---|
13 | {
|
---|
14 | std::array<double,3> probs;
|
---|
15 | probs[2] = 0.5; probs[1] = 0.9; probs[0] = 0.95;
|
---|
16 | typedef accumulator_set<double, stats<tag::extended_p_square> > accumulator_t;
|
---|
17 | accumulator_t acc(tag::extended_p_square::probabilities = probs);
|
---|
18 | for ( size_t i=0; i<=100; ++i )
|
---|
19 | {
|
---|
20 | acc(1.0*i);
|
---|
21 | }
|
---|
22 | double q0 = extended_p_square(acc)[0];
|
---|
23 | double q1 = extended_p_square(acc)[1];
|
---|
24 | double q2 = extended_p_square(acc)[2];
|
---|
25 | std::cout << q0 << " " << q1 << " " << q2 << std::endl;
|
---|
26 | EXPECT_DOUBLE_EQ(50.0, q0);
|
---|
27 | EXPECT_DOUBLE_EQ(90.0, q1);
|
---|
28 | EXPECT_DOUBLE_EQ(95.0, q2);
|
---|
29 | }
|
---|