簡體   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