CovariancePopAggregator

A CovariancePopAggregator is an Aggregator that returns the population covariance of two numeric properties as a Double. The population covariance is NaN if no non-null pairs of values were found, and it is zero if exactly one pair of non-null values was found. This Aggregator overrides the terminateDoubleDouble method, so that the population covariance is also available as a DoubleDouble. This allows the population covariance to be used by other Aggregators as a high-precision DoubleDouble.

Usage

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

  • Aggregator agg = new CovariancePopAggregator("propertyOne", "propertyTwo");
  • Aggregator agg = Aggregator.getAggregator("CovariancePop(propertyOne, propertyTwo)");

The values returned by the two properties of the object must be numeric.

The population covariance is calculated by summing up the products of both values' differences from their respective arithmetic means (averages), then dividing that sum by (n), where n is the number of occurrences where both properties are not null.