code: public static Distribution merge(Distribution prior, Distribution latest) {
      if (!bucketsNearlyEquals(prior, latest)) {
        throw new IllegalArgumentException(MSG_BUCKET_OPTIONS_MISMATCH);
      }
      if (prior.getBucketCountsCount() != latest.getBucketCountsCount()) {
        throw new IllegalArgumentException(MSG_BUCKET_COUNTS_MISMATCH);
      }
      if (prior.getCount() == 0) {
        return latest;
      }
  
      // Merge the distribution statistics
      Builder builder = latest.toBuilder();
      long oldCount = latest.getCount();
      double oldMean = latest.getMean();
      builder.setCount(prior.getCount() + oldCount);
      builder.setMaximum(Math.max(prior.getMaximum(), latest.getMaximum()));
      builder.setMinimum(Math.min(prior.getMinimum(), latest.getMinimum()));
      double newMean = (oldCount * oldMean + prior.getCount() * prior.getMean()) / builder.getCount();
      builder.setMean(newMean);
      double oldSumOfSquaredDeviation = latest.getSumOfSquaredDeviation();
      double newSumOfSquaredDeviation = oldSumOfSquaredDeviation + prior.getSumOfSquaredDeviation()
          + (oldCount * Math.pow((builder.getMean() - oldMean), 2))
          + (prior.getCount() * Math.pow((builder.getMean() - prior.getMean()), 2));
      builder.setSumOfSquaredDeviation(newSumOfSquaredDeviation);
  
      // Merge the bucket counts
      for (int i = 0; i < latest.getBucketCountsCount(); i++) {
        builder.setBucketCounts(i, prior.getBucketCounts(i) + latest.getBucketCounts(i));
      }
      return builder.build();
    }
docs: Merge {@code prior} with {@code latest}.
  
  @param prior a {@code Distribution} instance
  @param latest a {@code Distribution}, expected to be a later version of {@code prior}
  
  @return a new {@code Distribution} that combines the statistics and buckets of the earlier two
  @throws IllegalArgumentException if the bucket options of {@code prior} and {@code latest}
  don't match
  @throws IllegalArgumentException if the bucket counts of {@code prior} and {@code latest} dont'
  match