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