繁体   English   中英

Boost ::累加器的百分位数给出错误的值

[英]Boost::accumulator's percentile giving wrong values

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

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

我向累加器提供了一些样本值。

但是当我尝试使用boost::accumulators::quantile(m_acc, boost::accumulators::quantile_probability = probs[0]);来获取百分boost::accumulators::quantile(m_acc, boost::accumulators::quantile_probability = probs[0]); 它返回错误的值,有时甚至返回nan。

怎么了

我遇到了这个问题,浪费了很多时间找出问题,因此想回答这个问题。

问题出在向量上。 向量应按其值的升序排列。

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM