boostorg / boostorg/accumulators
Nans in quantile accumulators
- Dominant language
- C++
- Stars
- 26
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
This code is a slightly modified example from the Boost.Accumualators documentation, https://scicomp.ethz.ch/public/manual/Boost/1.55.0/accumulators.pdf , p.50.
It has two constants, `n`, `c` : sample size and cache size.
The purpose of this library, if I'm not mistaken, that the stats are computed for `c << n`.
However, this code yields nans and fails the test.
When the cache size is set equal to a sample size `c = n;` the test passes.
```
#include
#include
#include
#include
#include
#include
using namespace boost::accumulators;
int main() {
double epsilon = 1.e-2;
std::size_t n = 100000; // number of MC steps
std::size_t c = 10000; // cache size
typedef accumulator_set > > accumulator_t_right;
typedef accumulator_set > > accumulator_t_left;
accumulator_t_right acc0( tag::tail::cache_size = c );
accumulator_t_left acc2( tag::tail::cache_size = c );
boost::lagged_fibonacci607 rng;
for (std::size_t i = 0; i < n; ++i) {
double sample1 = rng();
acc0(sample1);
acc2(sample1);
}
std::cout << quantile(acc0, quantile_probability = 0.95) << std::endl;
std::cout << quantile(acc0, quantile_probability = 0.75) << std::endl;
std::cout << quantile(acc2, quantile_probability = 0.25) << std::endl;
std::cout << quantile(acc2, quantile_probability = 0.05) << std::endl;
assert(std::fabs(quantile(acc0, quantile_probability = 0.95 )- 0.95) < epsilon);
assert(std::fabs(quantile(acc0, quantile_probability = 0.975)- 0.975)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with boost/accumulators/statistics/tail_quantile.hpp and reproduce the issue using the supplied program with n=100000 and c=10000. Trace the right- and left-tail quantile accumulators, then verify that the supplied assertions pass without NaN results when the cache is much smaller than the sample size.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100