code: public double getRank(final float value) {
      if (isEmpty()) { return Double.NaN; }
      int level = 0;
      int weight = 1;
      long total = 0;
      while (level < numLevels_) {
        final int fromIndex = levels_[level];
        final int toIndex = levels_[level + 1]; // exclusive
        for (int i = fromIndex; i < toIndex; i++) {
          if (items_[i] < value) {
            total += weight;
          } else if ((level > 0) || isLevelZeroSorted_) {
            break; // levels above 0 are sorted, no point comparing further
          }
        }
        level++;
        weight *= 2;
      }
      return (double) total / n_;
    }
docs: Returns an approximation to the normalized (fractional) rank of the given value from 0 to 1,
  inclusive.
  
  <p>The resulting approximation has a probabilistic guarantee that be obtained from the
  getNormalizedRankError(false) function.
  
  <p>If the sketch is empty this returns NaN.</p>
  
  @param value to be ranked
  @return an approximate rank of the given value