Как установить политику округления для эмпирического распределения в функции квантиля? - PullRequest
1 голос
/ 24 апреля 2019

Я пытаюсь изменить значение параметра округления по умолчанию integer_round_outwards на integer_round_inwards для аккумулятора, который содержит эмпирическое дискретное распределение ( Discrete Quantile Policies ).

Я рассчитал количество из эмпирического распределения с политикой округления по умолчанию:

#include <boost/math/policies/policy.hpp>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/tail_quantile.hpp>

using namespace boost::accumulators;

typedef accumulator_set< double, stats< tag::tail_quantile<right> > > accumulator_t;

double myQuantile(double level, std::vector<double>& values){

    accumulator_t acc(boost::accumulators::tag::tail<right>::cache_size = values.size());

    for (const auto& sample : values) // Vector 'values' containing empirical measures
        acc(sample);                  // My accumulator 'acc' with the empirical discrete distribution

    double myResult = quantile(acc, quantile_probability = level);

    return myResult;                  // This result is under the integer_round_outwards rounding policy
};

Однако я хочу попробовать другие типы политик округления. В документации Boost показан следующий пример отрицательного биномиального распределения:

#include <boost/math/distributions/negative_binomial.hpp>

using boost::math::negative_binomial_distribution;
using namespace boost::math::policies;

typedef negative_binomial_distribution< double, policy<discrete_quantile<integer_round_nearest> > > dist_type;

// Lower quantile rounded (down) to nearest:
double x = quantile(dist_type(20, 0.3), 0.05); // 27

Как я могу сделать это для моего пользовательского аккумулятора, который содержит эмпирическое дискретное распределение?

Я использую Boost 1.63

...