public long mean()
    {
        int lastBucket = buckets.length() - 1;
        if (buckets.get(lastBucket) > 0)
            throw new IllegalStateException("Unable to compute ceiling for max when histogram overflowed");

        long elements = 0;
        long sum = 0;
        for (int i = 0; i < lastBucket; i++)
        {
            long bCount = buckets.get(i);
            elements += bCount;
            sum += bCount * bucketOffsets[i];
        }

        return (long) Math.ceil((double) sum / elements);
    }
public long mean ( ) { int lastBucket = buckets . length ( ) - 1 ; if ( buckets . get ( lastBucket ) > 0 ) throw new IllegalStateException ( "Unable to compute ceiling for max when histogram overflowed" ) ; long elements = 0 ; long sum = 0 ; for ( int i = 0 ; i < lastBucket ; i ++ ) { long bCount = buckets . get ( i ) ; elements += bCount ; sum += bCount * bucketOffsets [ i ] ; } return ( long ) Math . ceil ( ( double ) sum / elements ) ; }
@return the mean histogram value (average of bucket offsets, weighted by count)
@throws IllegalStateException if any values were greater than the largest bucket threshold