From 189b1a7affab5d3ad041d3fb15a0289a4b7db511 Mon Sep 17 00:00:00 2001 From: JonathanZailer <58289527+JonathanZailer@users.noreply.github.com> Date: Tue, 31 Mar 2020 17:52:31 +0300 Subject: [PATCH] fix weights it seems like the weights were in wrong order --- tdigest/tdigest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tdigest/tdigest.py b/tdigest/tdigest.py index ae79c61..d98f593 100644 --- a/tdigest/tdigest.py +++ b/tdigest/tdigest.py @@ -182,7 +182,7 @@ def percentile(self, p): if p < t + k: z1 = p - t z2 = t + k - p - return (c_i.mean * z2 + c_i_plus_one.mean * z1) / (z1 + z2) + return (c_i.mean * z1 + c_i_plus_one.mean * z2) / (z1 + z2) c_i = c_i_plus_one t += k