diff --git a/src/test/java/com/tdunning/math/stats/TDigestTest.java b/src/test/java/com/tdunning/math/stats/TDigestTest.java index 9cd527dd..1a7cf55d 100644 --- a/src/test/java/com/tdunning/math/stats/TDigestTest.java +++ b/src/test/java/com/tdunning/math/stats/TDigestTest.java @@ -246,6 +246,9 @@ public String call() throws Exception { for (Future result : executor.invokeAll(tasks)) { out.write(result.get()); } + } catch (Throwable e) { + e.printStackTrace(); + throw e; } finally { executor.shutdownNow(); executor.awaitTermination(5, TimeUnit.SECONDS); @@ -707,6 +710,24 @@ public void testThreePointExample() { // System.out.println(); } + @Test + public void testSingletonInACrowd() { + final double compression = 100; + TDigest dist = factory(compression).create(); + for (int i = 0; i < 10000; i++) { + dist.add(10); + } + dist.add(20); + dist.compress(); + assertEquals(10.0, dist.quantile(0), 0); + assertEquals(10.0, dist.quantile(0.5), 0); + assertEquals(10.0, dist.quantile(0.8), 0); + assertEquals(10.0, dist.quantile(0.9), 0); + assertEquals(10.0, dist.quantile(0.99), 0); + assertEquals(10.0, dist.quantile(0.999), 0); + assertEquals(20.0, dist.quantile(1), 0); + } + @Test public void testIntEncoding() { Random gen = getRandom();