VarianceAggregator

A VarianceAggregator is an Aggregator that returns the sample variance of a numeric property as a Double. The sample variance is NaN if no values were found, and it is zero if exactly one value was found. This Aggregator overrides the terminateDoubleDouble method, so that the sample variance is also available as a DoubleDouble. This allows the sample variance to be used by other Aggregators as a high-precision DoubleDouble.

Usage

Create and use a VarianceAggregator, with one of the following methods:

  • Aggregator agg = new VarianceAggregator("property");
  • Aggregator agg = Aggregator.getAggregator("Variance(property)");

The values returned by the property of the object must be numeric.

The sample variance is calculated by summing up the squares of the values' differences from their arithmetic mean (average), then dividing that sum by (n - 1), where n is the number of non-null occurrences.