int bucket(double x) {
        if (x <= min) {
            return 0;
        } else if (x >= max) {
            return counts.length - 1;
        } else {
            return bucketIndex(x);
        }
    }
int bucket ( double x ) { if ( x <= min ) { return 0 ; } else if ( x >= max ) { return counts . length - 1 ; } else { return bucketIndex ( x ) ; } }
exposed for testing