Boost :: accumulator的百分位给出了错误的值

时间:2016-06-23 06:21:10

标签: c++ boost-accumulators

我使用boost::accumulators::tag::extended_p_square_quantile来计算百分位数。在这里,我还需要将概率提供给累加器,所以我做了m_acc = AccumulatorType(boost::accumulators::extended_p_square_probabilities = probs);,其中probs是包含概率的向量。

概率向量中的值为{0.5,0.3,0.9,0.7}

我为累加器提供了一些示例值。

但是当我尝试使用boost::accumulators::quantile(m_acc, boost::accumulators::quantile_probability = probs[0]);获取百分位数时,它会返回不正确的值,有时甚至是纳米。

这里有什么问题?

1 个答案:

答案 0 :(得分:0)

我遇到了这个问题,浪费了很多时间来解决问题,因此想要回答这个问题。

问题在于矢量。矢量应按其值的递增顺序缩短。

将矢量值更改为此{0.3,0.5,0.7,0.9},它将按预期工作。

因此,如果有人使用tag::extended_p_square_quantile获取百分位数(支持多个概率),那么他需要按排序顺序给出概率(向量/数组/列表)。

tag::p_square_quantile不是这种情况,因为我们只能给出一个值(概率)。