code: public static <T> Collector<T, ?, Double>
      averagingDouble(ToDoubleFunction<? super T> mapper) {
          /*
           * In the arrays allocated for the collect operation, index 0
           * holds the high-order bits of the running sum, index 1 holds
           * the low-order bits of the sum computed via compensated
           * summation, and index 2 holds the number of values seen.
           */
          return new CollectorImpl<>(
                  () -> new double[4],
                  (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); a[2]++; a[3]+= mapper.applyAsDouble(t);},
                  (a, b) -> { sumWithCompensation(a, b[0]); sumWithCompensation(a, b[1]); a[2] += b[2]; a[3] += b[3]; return a; },
                  a -> (a[2] == 0) ? 0.0d : (computeFinalSum(a) / a[2]),
                  CH_NOID);
      }
docs: Returns a {@code Collector} that produces the arithmetic mean of a double-valued
  function applied to the input elements.  If no elements are present,
  the result is 0.
  
  <p>The average returned can vary depending upon the order in which
  values are recorded, due to accumulated rounding error in
  addition of values of differing magnitudes. Values sorted by increasing
  absolute magnitude tend to yield more accurate results.  If any recorded
  value is a {@code NaN} or the sum is at any point a {@code NaN} then the
  average will be {@code NaN}.
  
  @implNote The {@code double} format can represent all
  consecutive integers in the range -2<sup>53</sup> to
  2<sup>53</sup>. If the pipeline has more than 2<sup>53</sup>
  values, the divisor in the average computation will saturate at
  2<sup>53</sup>, leading to additional numerical errors.
  
  @param <T> the type of the input elements
  @param mapper a function extracting the property to be summed
  @return a {@code Collector} that produces the sum of a derived property