/** * Get the value at the given percentile. */ public double percentile(double percentile) { return get(percentile * getEventCount() / 100); }
/** * Get the value at the given percentile. */ public double percentile(double percentile) { return get(percentile * getEventCount() / 100); }
/** * Return the average of the histogram. */ public Optional<Double> avg() { if (isEmpty()) return Optional.empty(); return Optional.of(sum() / getEventCount()); }
/** * Return the average of the histogram. */ public Optional<Double> avg() { if (isEmpty()) return Optional.empty(); return Optional.of(sum() / getEventCount()); }
@Override protected AvgAgg map_(MetricValue x) { final Optional<AvgAgg> hist_params = x.histogram().map(h -> new AvgAgg(h.sum(), h.getEventCount())); if (hist_params.isPresent()) return hist_params.get(); return x.value() .map(Number::doubleValue) .map(x_number -> new AvgAgg(x_number, 1)) .orElseGet(() -> new AvgAgg(0, 0)); } @Override