-
Notifications
You must be signed in to change notification settings - Fork 230
Open
Description
Hi, I was testing some Kotlin code that uses the tdigest under the hood, and by accident found the following test case causes an AssertionError:
@Test
fun `tdigest bug`() {
val digest1 = MergingDigest(100.0)
val digest2 = MergingDigest(100.0)
repeat(4000) {
if (it < 1000)
digest1.add(it / 3999.0)
else
digest2.add(it / 3999.0)
}
digest1.add(digest2)
}This fails with:
java.lang.AssertionError
at com.tdunning.math.stats.MergingDigest.merge(MergingDigest.java:490)
at com.tdunning.math.stats.MergingDigest.mergeNewValues(MergingDigest.java:363)
at com.tdunning.math.stats.MergingDigest.mergeNewValues(MergingDigest.java:353)
at com.tdunning.math.stats.MergingDigest.add(MergingDigest.java:259)
at com.tdunning.math.stats.MergingDigest.add(MergingDigest.java:246)
at com.tdunning.math.stats.AbstractTDigest.add(AbstractTDigest.java:135)
at mycompany.latencyReporting.digest.QuantileDigestsTest.tdigest bug(QuantileDigestsTest.kt:157)
Which is this assert: assert weight[lastUsedCell - 1] == 1
Interestingly, running digest1.compress() before the merge prevents the issue. I'm wondering if perhaps this is related to #216.
This was with com.tdunning:t-digest:3.3. (And of course, thank you very much for your work!)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels