Skip to content

Commit d1cb0c9

Browse files
Fix quantile selection for upper bound
1 parent 2fa0247 commit d1cb0c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kll_sketch/kll_sketch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import struct
1313
import random
1414
import heapq
15-
from bisect import bisect_left
15+
from bisect import bisect_left, bisect_right
1616
from typing import Iterable, List, Tuple, Optional
1717

1818

@@ -399,7 +399,7 @@ def _batched_quantiles(self, qs: List[float]) -> List[float]:
399399
search_lo = 0
400400
for idx, q in ordered:
401401
target = q * (self._n - 1)
402-
pos = bisect_left(prefix, target - 1e-12, lo=search_lo)
402+
pos = bisect_right(prefix, target, lo=search_lo)
403403
if pos >= len(vals):
404404
pos = len(vals) - 1
405405
out[idx] = vals[pos]

0 commit comments

Comments
 (0)