public void add(double v) { counts[bucket(v)]++; }
int bucket(double x) { if (x <= min) { return 0; } else if (x >= max) { return counts.length - 1; } else { return bucketIndex(x); } }
@SuppressWarnings("WeakerAccess") public double[] getBounds() { double[] r = new double[counts.length]; for (int i = 0; i < r.length; i++) { r[i] = lowerBound(i); } return r; }
long[] k1 = dist1.getCounts(); long[] k2 = dist2.getCounts(); dist1.lowerBound(0) != dist2.lowerBound(0) || dist1.lowerBound(n1 - 1) != dist2.lowerBound(n1 - 1)) { throw new IllegalArgumentException("Incompatible histograms in terms of size or bounds");
protected void setupBins(double min, double max) { int binCount = bucketIndex(max) + 1; if (binCount > 10000) { throw new IllegalArgumentException( String.format("Excessive number of bins %d resulting from min,max = %.2g, %.2g", binCount, min, max)); } counts = new long[binCount]; }