private long estimateBias(long count) {
    double[] rawEstForP = HLLConstants.rawEstimateData[p - 4];

    // compute distance and store it in sorted map
    TreeMap<Double,Integer> estIndexMap = new TreeMap<>();
    double distance = 0;
    for (int i = 0; i < rawEstForP.length; i++) {
      distance = Math.pow(count - rawEstForP[i], 2);
      estIndexMap.put(distance, i);
    }

    // take top-k closest neighbors and compute the bias corrected cardinality
    long result = 0;
    double[] biasForP = HLLConstants.biasData[p - 4];
    double biasSum = 0;
    int kNeighbors = HLLConstants.K_NEAREST_NEIGHBOR;
    for (Map.Entry<Double, Integer> entry : estIndexMap.entrySet()) {
      biasSum += biasForP[entry.getValue()];
      kNeighbors--;
      if (kNeighbors <= 0) {
        break;
      }
    }

    // 0.5 added for rounding off
    result = (long) ((biasSum / HLLConstants.K_NEAREST_NEIGHBOR) + 0.5);
    return result;
  }
Estimate bias from lookup table
@param count
         - cardinality before bias correction
@return cardinality after bias correction
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/common/ndv/hll/HyperLogLog.java