boost accumulator tail_quantile,如何得到分位数

时间:2014-12-27 08:56:37

标签: c++ boost

按照我之前的问题。我根据boost 1.55 doc中给出的tail_quantile示例相应地修改了下面的代码 boost tail_quantile

#include <boost/accumulators/statistics/tail_quantile.hpp>
#include <boost/accumulators/framework/accumulator_set.hpp>
#include <boost/random/lagged_fibonacci.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/math/distributions/normal.hpp>

using namespace boost::accumulators;


void testTailQuantile()
{
    // tolerance in %
    double epsilon = 1;

    std::size_t n = 100000; // number of MC steps
    std::size_t c =  10000; // cache size
    typedef accumulator_set<double, stats<tag::tail_quantile<boost::accumulators::left> > > accumulator_t_left;
    accumulator_t_left acc0( left_tail_cache_size = c );
    boost::lagged_fibonacci607 rng;
    boost::normal_distribution<> mean_sigma(0,1);
    boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
    for (std::size_t i = 0; i < n; ++i)
    {
        double sample1 = rng();
        double sample2 = normal();
        acc0(sample1);
    }

    std::cout <<    quantile(acc0, quantile_probability = 0.95 ) << std::endl;
}

对于最后一行代码,“quantile(acc0 .....”报告错误如下:

In file included from ../src/LearnBoost.cpp:16:0:
../src/testBoostAccumulator.h: In function ‘void testTailQuantile()’:
../src/testBoostAccumulator.h:39:58: error: no match for call to ‘(const boost::accumulators::extractor<boost::accumulators::tag::quantile>) (accumulator_t_left&, const type)’
  std::cout << quantile(acc0, quantile_probability = 0.95 ) << std::endl;

我是否再次忘记了一些头文件或命名空间?

0 个答案:

没有答案