@Test public void percentile() { final Histogram h = new Histogram(new HashMap<Histogram.Range, Double>() { { put(new Histogram.Range(0, 1), 1d); put(new Histogram.Range(1, 2), 1d); put(new Histogram.Range(2, 6), 4d); put(new Histogram.Range(6, 7), 1d); put(new Histogram.Range(7, 10), 3d); } }.entrySet().stream().map(HistogramTest::map_)); assertEquals(0, h.percentile(0), 0.000001); assertEquals(10, h.percentile(100), 0.000001); assertEquals(5, h.percentile(50), 0.000001); assertEquals(9.9, h.percentile(99), 0.000001); assertEquals(6.9, h.percentile(69), 0.000001); }
public double percentile(double percentile) { return get(percentile * getEventCount() / 100); }
Histogram implements Serializable, Comparable<Histogram> { public double percentile(double percentile) { return get(percentile * getEventCount() / 100); } }
Histogram implements Serializable, Comparable<Histogram> { public double percentile(double percentile) { return get(percentile * getEventCount() / 100); } Histogram(RangeWithCount... items);  Histogram(Stream<RangeWithCount> items); }
Histogram implements Serializable, Comparable<Histogram> { public double percentile(double percentile) { return get(percentile * getEventCount() / 100); } Histogram(RangeWithCount... items);  Histogram(Stream<RangeWithCount> items); Stream<RangeWithCount> stream(); double getEventCount(); boolean isEmpty(); Optional<Double> min(); Optional<Double> max(); Optional<Double> median(); Optional<Double> avg(); double sum(); double get(double index); double percentile(double percentile); Histogram modifyEventCounters(BiFunction<Range, Double, Double> fn); static Histogram add(Histogram x, Histogram y); static Histogram negate(Histogram x); static Histogram subtract(Histogram x, Histogram y); static Histogram multiply(Histogram x, double y); static Histogram divide(Histogram x, double y); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Histogram o); @Override String toString(); }
Histogram implements Serializable, Comparable<Histogram> { public double percentile(double percentile) { return get(percentile * getEventCount() / 100); } Histogram(RangeWithCount... items);  Histogram(Stream<RangeWithCount> items); Stream<RangeWithCount> stream(); double getEventCount(); boolean isEmpty(); Optional<Double> min(); Optional<Double> max(); Optional<Double> median(); Optional<Double> avg(); double sum(); double get(double index); double percentile(double percentile); Histogram modifyEventCounters(BiFunction<Range, Double, Double> fn); static Histogram add(Histogram x, Histogram y); static Histogram negate(Histogram x); static Histogram subtract(Histogram x, Histogram y); static Histogram multiply(Histogram x, double y); static Histogram divide(Histogram x, double y); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Histogram o); @Override String toString();  }