DoubleSummaryStatistics

public class DoubleSummaryStatistics extends Object
implements DoubleConsumer

A state object for collecting statistics such as count, min, max, sum, and average.

This class is designed to work with (though does not require) {@linkplain java.util.stream streams}. For example, you can compute summary statistics on a stream of doubles with:

 DoubleSummaryStatistics stats = doubleStream.collect(DoubleSummaryStatistics::new,
                                                      DoubleSummaryStatistics::accept,
                                                      DoubleSummaryStatistics::combine);
 

DoubleSummaryStatistics can be used as a {@linkplain java.util.stream.Stream#collect(Collector) reduction} target for a {@linkplain java.util.stream.Stream stream}. For example:

 DoubleSummaryStatistics stats = people.stream()
     .collect(Collectors.summarizingDouble(Person::getWeight));
This computes, in a single pass, the count of people, as well as the minimum, maximum, sum, and average of their weights.

Public Constructor Summary

DoubleSummaryStatistics()
Construct an empty instance with zero count, zero sum, Double.POSITIVE_INFINITY min, Double.NEGATIVE_INFINITY max and zero average.

Public Method Summary

void
accept(double value)
Records another value into the summary information.
void
combine(DoubleSummaryStatistics other)
Combines the state of another DoubleSummaryStatistics into this one.
final double
getAverage()
Returns the arithmetic mean of values recorded, or zero if no values have been recorded.
final long
getCount()
Return the count of values recorded.
final double
getMax()
Returns the maximum recorded value, Double.NaN if any recorded value was NaN or Double.NEGATIVE_INFINITY if no values were recorded.
final double
getMin()
Returns the minimum recorded value, Double.NaN if any recorded value was NaN or Double.POSITIVE_INFINITY if no values were recorded.
final double
getSum()
Returns the sum of values recorded, or zero if no values have been recorded.