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 ; }
Get a sum of bucket counts from either the start of a histogram s range or end up to a specified cutoff value .