boostorg / boostorg/accumulators
p_square_quantile incorrect for few observations
- Dominant language
- C++
- Stars
- 26
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
The P^2 algorithms assumes that 5 observations are available from the beginning.
The `p_square_quantile` class make the same assumption, and it always returns the middle height (index 2) even when there are less than 6 observations.
A special case is needed for count < 6.
A solution is to always sort the heights when count < 6. Then we can return something like this (where `cnt` is the current count)
```
result_type result(dont_care) const
{
if (cnt >= 6)
{
return this->height[2];
}
else
{
const std::size_t nearest_rank = std::ceil(cnt * p);
return this->height[nearest_rank - 1];
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.