Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible bug in td_trimmed_mean #8

Open
tvondra opened this issue Dec 27, 2020 · 5 comments
Open

possible bug in td_trimmed_mean #8

tvondra opened this issue Dec 27, 2020 · 5 comments

Comments

@tvondra
Copy link

tvondra commented Dec 27, 2020

if (n->count < left_tail_count) {

I believe this condition

          if (n->count < left_tail_count) {
               continue;
          }

should really be

          if (count_seen + n->count < left_tail_count) {
               continue;
          }

otherwise the code may not consider some relevant centroids.

@ajwerner
Copy link
Owner

Good catch, that's pretty egregious.

@ajwerner
Copy link
Owner

Not that explaining the source of bugs is all that valuable, the source of this bug is that I ported td_trimmed_mean back from https://github.com/ajwerner/tdigest/blob/9165f388a6b2c88703b9630c9d15e59d2d212d7e/internal/tdigest/tdigest.go#L17. In the go repo, which I've invested a bit more into than this one, the counts maintain a cumulative count value when used for reading. That cumulative value enables binary search for td_value_at.

@tvondra
Copy link
Author

tvondra commented Jan 2, 2021

Understood. I've made plenty such bugs ;-)

@kdarby-cqg
Copy link

Hi, did this get fixed?

@ajwerner
Copy link
Owner

Doesn't look like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants