Class AggregateSummaryStatistics
- All Implemented Interfaces:
Serializable
,StatisticalSummary
An aggregator for SummaryStatistics
from several data sets or
data set partitions. In its simplest usage mode, the client creates an
instance via the zero-argument constructor, then uses
createContributingStatistics()
to obtain a SummaryStatistics
for each individual data set / partition. The per-set statistics objects
are used as normal, and at any time the aggregate statistics for all the
contributors can be obtained from this object.
Clients with specialized requirements can use alternative constructors to
control the statistics implementations and initial values used by the
contributing and the internal aggregate SummaryStatistics
objects.
A static aggregate(Collection)
method is also included that computes
aggregate statistics directly from a Collection of SummaryStatistics instances.
When createContributingStatistics()
is used to create SummaryStatistics
instances to be aggregated concurrently, the created instances'
SummaryStatistics.addValue(double)
methods must synchronize on the aggregating
instance maintained by this class. In multithreaded environments, if the functionality
provided by aggregate(Collection)
is adequate, that method should be used
to avoid unnecessary computation and synchronization delays.
- Since:
- 2.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new AggregateSummaryStatistics with default statistics implementations.AggregateSummaryStatistics
(SummaryStatistics prototypeStatistics) Initializes a new AggregateSummaryStatistics with the specified statistics object as a prototype for contributing statistics and for the internal aggregate statistics.AggregateSummaryStatistics
(SummaryStatistics prototypeStatistics, SummaryStatistics initialStatistics) Initializes a new AggregateSummaryStatistics with the specified statistics object as a prototype for contributing statistics and for the internal aggregate statistics. -
Method Summary
Modifier and TypeMethodDescriptionstatic StatisticalSummaryValues
aggregate
(Collection<? extends StatisticalSummary> statistics) Computes aggregate summary statistics.Creates and returns aSummaryStatistics
whose data will be aggregated with those of thisAggregateSummaryStatistics
.double
Returns the geometric mean of all the aggregated data.double
getMax()
Returns the maximum of the available valuesdouble
getMean()
Returns the arithmetic mean of the available valuesdouble
getMin()
Returns the minimum of the available valueslong
getN()
Returns the number of available valuesdouble
Returns a statistic related to the Second Central Moment.double
Returns the standard deviation of the available values.double
getSum()
Returns the sum of the values that have been added to Univariate.Return aStatisticalSummaryValues
instance reporting current aggregate statistics.double
Returns the sum of the logs of all the aggregated data.double
getSumsq()
Returns the sum of the squares of all the aggregated data.double
Returns the variance of the available values.
-
Constructor Details
-
AggregateSummaryStatistics
public AggregateSummaryStatistics()Initializes a new AggregateSummaryStatistics with default statistics implementations. -
AggregateSummaryStatistics
public AggregateSummaryStatistics(SummaryStatistics prototypeStatistics) throws NullArgumentException Initializes a new AggregateSummaryStatistics with the specified statistics object as a prototype for contributing statistics and for the internal aggregate statistics. This provides for customized statistics implementations to be used by contributing and aggregate statistics.- Parameters:
prototypeStatistics
- aSummaryStatistics
serving as a prototype both for the internal aggregate statistics and for contributing statistics obtained via thecreateContributingStatistics()
method. Being a prototype means that other objects are initialized by copying this object's state. Ifnull
, a new, default statistics object is used. Any statistic values in the prototype are propagated to contributing statistics objects and (once) into these aggregate statistics.- Throws:
NullArgumentException
- if prototypeStatistics is null- See Also:
-
AggregateSummaryStatistics
public AggregateSummaryStatistics(SummaryStatistics prototypeStatistics, SummaryStatistics initialStatistics) Initializes a new AggregateSummaryStatistics with the specified statistics object as a prototype for contributing statistics and for the internal aggregate statistics. This provides for different statistics implementations to be used by contributing and aggregate statistics and for an initial state to be supplied for the aggregate statistics.- Parameters:
prototypeStatistics
- aSummaryStatistics
serving as a prototype both for the internal aggregate statistics and for contributing statistics obtained via thecreateContributingStatistics()
method. Being a prototype means that other objects are initialized by copying this object's state. Ifnull
, a new, default statistics object is used. Any statistic values in the prototype are propagated to contributing statistics objects, but not into these aggregate statistics.initialStatistics
- aSummaryStatistics
to serve as the internal aggregate statistics object. Ifnull
, a new, default statistics object is used.- See Also:
-
-
Method Details
-
getMax
public double getMax()Returns the maximum of the available values. This version returns the maximum over all the aggregated data.- Specified by:
getMax
in interfaceStatisticalSummary
- Returns:
- The max or Double.NaN if no values have been added.
- See Also:
-
getMean
public double getMean()Returns the arithmetic mean of the available values. This version returns the mean of all the aggregated data.- Specified by:
getMean
in interfaceStatisticalSummary
- Returns:
- The mean or Double.NaN if no values have been added.
- See Also:
-
getMin
public double getMin()Returns the minimum of the available values. This version returns the minimum over all the aggregated data.- Specified by:
getMin
in interfaceStatisticalSummary
- Returns:
- The min or Double.NaN if no values have been added.
- See Also:
-
getN
public long getN()Returns the number of available values. This version returns a count of all the aggregated data.- Specified by:
getN
in interfaceStatisticalSummary
- Returns:
- The number of available values
- See Also:
-
getStandardDeviation
public double getStandardDeviation()Returns the standard deviation of the available values.. This version returns the standard deviation of all the aggregated data.- Specified by:
getStandardDeviation
in interfaceStatisticalSummary
- Returns:
- The standard deviation, Double.NaN if no values have been added or 0.0 for a single value set.
- See Also:
-
getSum
public double getSum()Returns the sum of the values that have been added to Univariate.. This version returns a sum of all the aggregated data.- Specified by:
getSum
in interfaceStatisticalSummary
- Returns:
- The sum or Double.NaN if no values have been added
- See Also:
-
getVariance
public double getVariance()Returns the variance of the available values.. This version returns the variance of all the aggregated data.- Specified by:
getVariance
in interfaceStatisticalSummary
- Returns:
- The variance, Double.NaN if no values have been added or 0.0 for a single value set.
- See Also:
-
getSumOfLogs
public double getSumOfLogs()Returns the sum of the logs of all the aggregated data.- Returns:
- the sum of logs
- See Also:
-
getGeometricMean
public double getGeometricMean()Returns the geometric mean of all the aggregated data.- Returns:
- the geometric mean
- See Also:
-
getSumsq
public double getSumsq()Returns the sum of the squares of all the aggregated data.- Returns:
- The sum of squares
- See Also:
-
getSecondMoment
public double getSecondMoment()Returns a statistic related to the Second Central Moment. Specifically, what is returned is the sum of squared deviations from the sample mean among the all of the aggregated data.- Returns:
- second central moment statistic
- See Also:
-
getSummary
Return aStatisticalSummaryValues
instance reporting current aggregate statistics.- Returns:
- Current values of aggregate statistics
-
createContributingStatistics
Creates and returns aSummaryStatistics
whose data will be aggregated with those of thisAggregateSummaryStatistics
.- Returns:
- a
SummaryStatistics
whose data will be aggregated with those of thisAggregateSummaryStatistics
. The initial state is a copy of the configured prototype statistics.
-
aggregate
public static StatisticalSummaryValues aggregate(Collection<? extends StatisticalSummary> statistics) Computes aggregate summary statistics. This method can be used to combine statistics computed over partitions or subsamples - i.e., the StatisticalSummaryValues returned should contain the same values that would have been obtained by computing a single StatisticalSummary over the combined dataset.Returns null if the collection is empty or null.
- Parameters:
statistics
- collection of SummaryStatistics to aggregate- Returns:
- summary statistics for the combined dataset
-