我正在尝试将包含经验离散分布(Discrete Quantile Policies)的累加器的默认舍入参数值integer_round_outwards
更改为integer_round_inwards
。
我已经使用默认的舍入策略根据经验分布计算了数量:
#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