Skip to content

fix(tdigest): preserve stored min and max when merging - #183

Merged
proost merged 1 commit into
apache:mainfrom
jaideeppyne:fix/tdigest-merge-minmax
Sep 17, 2026
Merged

proost merged 1 commit into
apache:mainfrom
jaideeppyne:fix/tdigest-merge-minmax

Conversation

@jaideeppyne

Copy link
Copy Markdown
Contributor

Summary

  • Copy the stored min/max from the other digest in Double.Merge before compressing the combined centroid list.
  • Add a regression that merges a digest constructed with weighted tail centroids whose means are not the true extrema.

Why

Merge previously re-derived extrema from the extreme centroid means. That is exact only when those centroids have unit weight. Deserialized images can have weighted tails, so min/max drifted inward and rank/quantile tail interpolation used the wrong endpoints.

Same defect as apache/datasketches-rust#277.

Validation

  • go test ./tdigest -run TestDouble_Merge

Merging a digest whose extreme centroids have weight greater than one
re-derived min and max from those centroid means. Copy the stored extrema
from the other digest first so rank and quantile tail interpolation stay
correct, especially for deserialized images.

@proost proost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@proost
proost merged commit 0211c4f into apache:main Sep 17, 2026
5 checks passed
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.

2 participants