public int toBin(double x) {
            int binNumber = (int) ((x - min) / bucketWidth);
            if (binNumber < MIN_BIN_NUMBER) {
                return MIN_BIN_NUMBER;
            }
            return Math.min(binNumber, maxBinNumber);
        }
Create a bin scheme with the specified number of bins that all have the same width.

@param bins the number of bins; must be at least 2
@param min the minimum value to be counted in the bins
@param max the maximum value to be counted in the bins
clients/src/main/java/org/apache/kafka/common/metrics/stats/Histogram.java