Skip to content

Commit 6100bc6

Browse files
committed
Add test case for quantile in zero-bucket
1 parent 25be13d commit 6100bc6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libs/exponential-histogram/src/test/java/org/elasticsearch/exponentialhistogram/QuantileAccuracyTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.stream.IntStream;
2828

2929
import static org.hamcrest.Matchers.closeTo;
30+
import static org.hamcrest.Matchers.equalTo;
3031
import static org.hamcrest.Matchers.lessThan;
3132
import static org.hamcrest.Matchers.notANumber;
3233

@@ -68,6 +69,13 @@ public void testBasicSmall() {
6869
assertThat(maxError, lessThan(0.000001));
6970
}
7071

72+
public void testPercentileOverlapsZeroBucket() {
73+
ExponentialHistogram histo = ExponentialHistogramGenerator.createFor(-1, 0, 1);
74+
assertThat(ExponentialHistogramQuantile.getQuantile(histo, 0.5), equalTo(0.0));
75+
assertThat(ExponentialHistogramQuantile.getQuantile(histo, 0.375), closeTo(-0.5, 0.000001));
76+
assertThat(ExponentialHistogramQuantile.getQuantile(histo, 0.625), closeTo(0.5, 0.000001));
77+
}
78+
7179
public void testBigJump() {
7280
double[] values = DoubleStream.concat(IntStream.range(0, 18).mapToDouble(Double::valueOf), DoubleStream.of(1_000_000.0)).toArray();
7381

0 commit comments

Comments
 (0)