/** Observe the given amount. */ public void observe(double amt) { for (int i = 0; i < upperBounds.length; ++i) { // The last bucket is +Inf, so we always increment. if (amt <= upperBounds[i]) { cumulativeCounts[i].add(1); break; } } sum.add(amt); }
/** * Get the value of the Histogram. * * <p><em>Warning:</em> The definition of {@link Value} is subject to change. */ public Value get() { Value v = new Value(); v.buckets = new double[cumulativeCounts.length]; double acc = 0; for (int i = 0; i < cumulativeCounts.length; ++i) { acc += cumulativeCounts[i].sum(); v.buckets[i] = acc; } v.sum = sum.sum(); return v; }