code: public SampleSubsetSummary estimateSubsetSum(final Predicate<Long> predicate) {
      if (itemsSeen_ == 0) {
        return new SampleSubsetSummary(0.0, 0.0, 0.0, 0.0);
      }
  
      final long numSamples = getNumSamples();
      final double samplingRate = numSamples / (double) itemsSeen_;
      assert samplingRate >= 0.0;
      assert samplingRate <= 1.0;
  
      int predTrueCount = 0;
      for (int i = 0; i < numSamples; ++i) {
        if (predicate.test(data_[i])) {
          ++predTrueCount;
        }
      }
  
      // if in exact mode, we can return an exact answer
      if (itemsSeen_ <= reservoirSize_) {
        return new SampleSubsetSummary(predTrueCount, predTrueCount, predTrueCount, numSamples);
      }
  
      final double lbTrueFraction = pseudoHypergeometricLBonP(numSamples, predTrueCount, samplingRate);
      final double estimatedTrueFraction = (1.0 * predTrueCount) / numSamples;
      final double ubTrueFraction = pseudoHypergeometricUBonP(numSamples, predTrueCount, samplingRate);
      return new SampleSubsetSummary(
              itemsSeen_ * lbTrueFraction,
              itemsSeen_ * estimatedTrueFraction,
              itemsSeen_ * ubTrueFraction,
              itemsSeen_);
    }
docs: Computes an estimated subset sum from the entire stream for objects matching a given
  predicate. Provides a lower bound, estimate, and upper bound using a target of 2 standard
  deviations.
  
  <p>This is technically a heuristic method, and tries to err on the conservative side.</p>
  
  @param predicate A predicate to use when identifying items.
  @return A summary object containing the estimate, upper and lower bounds, and the total
  sketch weight.