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

Fixed td_quantile returning NaN when 1 sample #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bjornite
Copy link

@bjornite bjornite commented Apr 26, 2023

When the t-digest has only a single sample, td_quantile returns NaN when it should return the value of the single sample.

The problem is that td_compress does not update the merged_nodes counter when there is only a single value.

Fix is to check on (merged_nodes + unmerged_nodes)

Steps to reproduce:

#include <cmocka.h>

td_histogram_t *h = td_new(50.0);
td_add(h, 0.2, 1);
assert_true(td_quantile(h, 0.5) == 0.2);

@filipecosta90 filipecosta90 self-requested a review April 26, 2023 20:46
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

Successfully merging this pull request may close these issues.

1 participant