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

Quantile broken if only one centroid #17

Closed
pjz opened this issue Jun 15, 2016 · 4 comments
Closed

Quantile broken if only one centroid #17

pjz opened this issue Jun 15, 2016 · 4 comments

Comments

@pjz
Copy link
Contributor

pjz commented Jun 15, 2016

>>> from tdigest import TDigest as TD
>>> td = TD()
>>> td.update(1)
>>> td.quantile(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tdigest/tdigest.py", line 184, in quantile
    delta = (c_i.mean - self.C.prev_item(key)[1].mean) / 2.
  File "/usr/local/lib/python2.7/dist-packages/bintrees/abctree.py", line 684, in prev_item
    raise KeyError(str(key))
KeyError: '1.0'

a little bit of inspection shows that quantile breaks if there's only one Centroid in self.C.

@CamDavidsonPilon
Copy link
Owner

Thanks for reporting this. I'll fix this shortly, unless you have PR in mind

@pjz
Copy link
Contributor Author

pjz commented Jun 15, 2016

I have some tests, but they're fairly trivial. I have a PR, but I'm not entirely sure the math is correct on it. I'll submit shortly and you can have a look.

pjz added a commit to pjz/tdigest that referenced this issue Jun 15, 2016
pjz added a commit to pjz/tdigest that referenced this issue Jun 15, 2016
@pjz pjz mentioned this issue Jun 15, 2016
@pjz
Copy link
Contributor Author

pjz commented Jun 15, 2016

Looking forward to a fix, even if it's not mine!

pjz added a commit to pjz/tdigest that referenced this issue Jul 20, 2016
pjz added a commit to pjz/tdigest that referenced this issue Jul 20, 2016
pjz added a commit to pjz/tdigest that referenced this issue Jul 20, 2016
@pjz
Copy link
Contributor Author

pjz commented Jul 21, 2016

Fixed by #19

@pjz pjz closed this as completed Jul 21, 2016
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

2 participants