From 3037b486643c6843fd97f90d3c4ebe8f7a349a39 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Fri, 25 Aug 2023 12:02:55 -0400 Subject: [PATCH] fix trimmed mean as suggested by tvondra https://github.com/ajwerner/tdigestc/issues/8 --- go/tdigest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/tdigest.c b/go/tdigest.c index b2a1e13..3c71890 100644 --- a/go/tdigest.c +++ b/go/tdigest.c @@ -229,7 +229,7 @@ double td_trimmed_mean(td_histogram_t *h, double lo, double hi) { count_seen += h->nodes[i-1].count; } node_t *n = &h->nodes[i]; - if (n->count < left_tail_count) { + if (count_seen + n->count < left_tail_count) { continue; } if (count_seen > right_tail_count) {