jaideeppyne opened a new pull request, #755: URL: https://github.com/apache/datasketches-java/pull/755
`getRank()` interpolates the left tail but never divides the result by `centroidsWeight_`. The right tail branch immediately below it does, and so does the reference implementation ([MergingDigest.cdf](https://github.com/tdunning/t-digest/blob/main/core/src/main/java/com/tdunning/math/stats/MergingDigest.java#L602)): ```java return (1 + (x - min) / (mean[0] - min) * (weight[0] / 2 - 1)) / totalWeight; ``` You can't reach it from `update()` or `merge()`, because `compress()` always leaves the first centroid a singleton. You can reach it from `heapify()`: the format allows a first centroid with weight > 1 and deserialization accepts it. On a digest with min 0, centroids (10, 100), (20, 100), (30, 100) and max 40: ``` value getRank() reference 0.0 0.001667 0.001667 1.0 5.90 0.01967 5.0 25.5 0.08500 9.0 45.1 0.1503 ``` `getCDF` and `getPMF` follow it out. `getCDF([5, 20, 35])` returns `[25.5, 0.5, 0.915, 1.0]`, which is neither monotonic nor in range, and `getPMF([5, 20, 35])` returns a negative mass of `-25.0`. The fix is the missing divisor. The new test builds that state through `heapify` and checks the left tail is normalized and non-decreasing. C++ has the identical line ([tdigest_impl.hpp#L133](https://github.com/apache/datasketches-cpp/blob/master/tdigest/include/tdigest_impl.hpp#L133)), marked `// ?` by the author, so it likely wants the same change. Full suite is 39 failures before and after, all in `*CrossLanguageTest` from missing `cpp_generated_files` fixtures, unrelated to this. I used Claude Code on this. The oracle was tdunning's `MergingDigest.cdf` plus the right tail branch as its own mirror image. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
