This is an automated email from the ASF dual-hosted git repository.

tison pushed a commit to branch fix-tdigest-quantile-cal
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git

commit cbc835742ae1f6391d73246534d26d816fb5c972
Author: tison <[email protected]>
AuthorDate: Wed Jan 7 13:55:02 2026 +0800

    fix: tdigest quantile edge case
    
    Signed-off-by: tison <[email protected]>
---
 datasketches/src/tdigest/sketch.rs | 2 +-
 datasketches/tests/tdigest_test.rs | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/datasketches/src/tdigest/sketch.rs 
b/datasketches/src/tdigest/sketch.rs
index 037953d..91c90c7 100644
--- a/datasketches/src/tdigest/sketch.rs
+++ b/datasketches/src/tdigest/sketch.rs
@@ -1175,7 +1175,7 @@ impl TDigestView<'_> {
                 }
                 let mut right_weight = 0.;
                 if self.centroids[i + 1].weight.get() == 1 {
-                    if weight_so_far + dw - weight < 0.5 {
+                    if weight_so_far + dw - weight <= 0.5 {
                         return Some(self.centroids[i + 1].mean);
                     }
                     right_weight = 0.5;
diff --git a/datasketches/tests/tdigest_test.rs 
b/datasketches/tests/tdigest_test.rs
index 870f3de..b61d779 100644
--- a/datasketches/tests/tdigest_test.rs
+++ b/datasketches/tests/tdigest_test.rs
@@ -228,3 +228,12 @@ fn test_invalid_inputs() {
     }
     assert!(td.is_empty());
 }
+
+#[test]
+fn test_estimate_repeat_values() {
+    let mut tdigest = TDigestMut::default();
+    for _ in 0..20 {
+        tdigest.update(1.0);
+    }
+    assert_eq!(tdigest.quantile(0.9), Some(1.0));
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to