1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| public static void main(String[] args) { double relativeAccuracy = 0.1; DDSketch sketch = DDSketches.unboundedDense(relativeAccuracy);
sketch.accept(3.2); sketch.accept(2.1, 3); DoubleStream.of(3.4, 7.6, 2.8,112,23,1,233).forEach(sketch);
final double[] valuesAtQuantiles = sketch.getValuesAtQuantiles(new double[]{1, 0.99, 0.95, 0.5, 0.1});
final double valueAtQuantile = sketch.getValueAtQuantile(0.5); final double p95Value = sketch.getValueAtQuantile(0.99); final double p100Value = sketch.getValueAtQuantile(1); final double minValue = sketch.getMinValue(); final double maxValue = sketch.getMaxValue();
System.out.printf("valueAtQuantile: %f, p95Value: %f, p100Value: %f, minValue: %f, maxValue: %f%n", valueAtQuantile, p95Value,p100Value, minValue, maxValue);
}
|