code: private double getCumulativeCount(double cutoff, boolean fromStart)
    {
      int cutoffBucket = (int) ((cutoff - lowerLimit) / bucketSize);
      double count = 0;
  
      if (fromStart) {
        for (int i = 0; i <= cutoffBucket; i++) {
          if (i == cutoffBucket) {
            double bucketStart = i * bucketSize + lowerLimit;
            double partialCount = ((cutoff - bucketStart) / bucketSize) * histogram[i];
            count += partialCount;
          } else {
            count += histogram[i];
          }
        }
      } else {
        for (int i = cutoffBucket; i < histogram.length; i++) {
          if (i == cutoffBucket) {
            double bucketEnd = ((i + 1) * bucketSize) + lowerLimit;
            double partialCount = ((bucketEnd - cutoff) / bucketSize) * histogram[i];
            count += partialCount;
          } else {
            count += histogram[i];
          }
        }
      }
      return count;
    }
docs: Get a sum of bucket counts from either the start of a histogram's range or end, up to a specified cutoff value.
  
  For example, if I have the following histogram with a range of 0-40, with 4 buckets and
  per-bucket counts of 5, 2, 10, and 7:
  
  |   5   |   2   |   24   |   7   |
  0       10      20       30      40
  
  Calling this function with a cutoff of 25 and fromStart = true would:
  - Sum the first two bucket counts 5 + 2
  - Since the cutoff falls in the third bucket, multiply the third bucket's count by the fraction of the bucket range
  covered by the cutoff, in this case the fraction is ((25 - 20) / 10) = 0.5
  - The total count returned is 5 + 2 + 12
  
  @param cutoff Cutoff point within the histogram's range
  @param fromStart If true, sum the bucket counts starting from the beginning of the histogram range.
  If false, sum from the other direction, starting from the end of the histogram range.
  @return Sum of bucket counts up to the cutoff point