Top Description Inners Fields Constructors Methods
org.apache.commons.math3.stat.descriptive

public Class AggregateSummaryStatistics

extends Object
implements StatisticalSummary, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.stat.descriptive.StatisticalSummary
Imports
java.io.Serializable, java.util.Collection, .Iterator, org.apache.commons.math3.exception.NullArgumentException

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AggregateSummaryStatistics.AggregatingSummaryStatistics

A SummaryStatistics that also forwards all values added to it to a second SummaryStatistics for aggregation.

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

Serializable version identifier

private final SummaryStatistics
statistics

The SummaryStatistics in which aggregate statistics are accumulated.

private final SummaryStatistics
statisticsPrototype

A SummaryStatistics serving as a prototype for creating SummaryStatistics contributing to this aggregate

Constructor Summary

AccessConstructor and Description
public
AggregateSummaryStatistics()

Initializes a new AggregateSummaryStatistics with default statistics implementations.

public
AggregateSummaryStatistics(SummaryStatistics
a SummaryStatistics serving as a prototype both for the internal aggregate statistics and for contributing statistics obtained via the createContributingStatistics() method. Being a prototype means that other objects are initialized by copying this object's state. If null, 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.
prototypeStatistics
)

Initializes a new AggregateSummaryStatistics with the specified statistics object as a prototype for contributing statistics and for the internal aggregate statistics.

public
AggregateSummaryStatistics(SummaryStatistics
a SummaryStatistics serving as a prototype both for the internal aggregate statistics and for contributing statistics obtained via the createContributingStatistics() method. Being a prototype means that other objects are initialized by copying this object's state. If null, 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.
prototypeStatistics
,
SummaryStatistics
a SummaryStatistics to serve as the internal aggregate statistics object. If null, a new, default statistics object is used.
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 TypeMethod and Description
public static StatisticalSummaryValues

Returns:

summary statistics for the combined dataset
aggregate
(Collection<? extends StatisticalSummary>
collection of SummaryStatistics to aggregate
statistics
)

Computes aggregate summary statistics.

public SummaryStatistics

Returns:

a SummaryStatistics whose data will be aggregated with those of this AggregateSummaryStatistics. The initial state is a copy of the configured prototype statistics.
createContributingStatistics
()

Creates and returns a SummaryStatistics whose data will be aggregated with those of this AggregateSummaryStatistics.

public double

Returns:

the geometric mean
getGeometricMean
()

Returns the geometric mean of all the aggregated data.

public double
getMax()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getMax.

Returns the maximum of the available values.

public double
public double
getMin()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getMin.

Returns the minimum of the available values.

public long
getN()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getN.

Returns the number of available values.

public double

Returns:

second central moment statistic
getSecondMoment
()

Returns a statistic related to the Second Central Moment.

public double
getStandardDeviation()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getStandardDeviation.

Returns the standard deviation of the available values..

public double
getSum()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getSum.

Returns the sum of the values that have been added to Univariate..

public StatisticalSummary

Returns:

Current values of aggregate statistics
getSummary
()

Return a StatisticalSummaryValues instance reporting current aggregate statistics.

public double

Returns:

the sum of logs
getSumOfLogs
()

Returns the sum of the logs of all the aggregated data.

public double

Returns:

The sum of squares
getSumsq
()

Returns the sum of the squares of all the aggregated data.

public double
getVariance()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getVariance.

Returns the variance of the available values..

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Serializable version identifier

statisticsback to summary
private final SummaryStatistics statistics

The SummaryStatistics in which aggregate statistics are accumulated.

statisticsPrototypeback to summary
private final SummaryStatistics statisticsPrototype

A SummaryStatistics serving as a prototype for creating SummaryStatistics contributing to this aggregate

Constructor Detail

AggregateSummaryStatisticsback to summary
public AggregateSummaryStatistics()

Initializes a new AggregateSummaryStatistics with default statistics implementations.

AggregateSummaryStatisticsback to summary
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:SummaryStatistics

a SummaryStatistics serving as a prototype both for the internal aggregate statistics and for contributing statistics obtained via the createContributingStatistics() method. Being a prototype means that other objects are initialized by copying this object's state. If null, 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.

Exceptions
NullArgumentException:
if prototypeStatistics is null
See Also
createContributingStatistics()
AggregateSummaryStatisticsback to summary
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:SummaryStatistics

a SummaryStatistics serving as a prototype both for the internal aggregate statistics and for contributing statistics obtained via the createContributingStatistics() method. Being a prototype means that other objects are initialized by copying this object's state. If null, 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:SummaryStatistics

a SummaryStatistics to serve as the internal aggregate statistics object. If null, a new, default statistics object is used.

See Also
createContributingStatistics()

Method Detail

aggregateback to summary
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<? extends StatisticalSummary>

collection of SummaryStatistics to aggregate

Returns:StatisticalSummaryValues

summary statistics for the combined dataset

createContributingStatisticsback to summary
public SummaryStatistics createContributingStatistics()

Creates and returns a SummaryStatistics whose data will be aggregated with those of this AggregateSummaryStatistics.

Returns:SummaryStatistics

a SummaryStatistics whose data will be aggregated with those of this AggregateSummaryStatistics. The initial state is a copy of the configured prototype statistics.

getGeometricMeanback to summary
public double getGeometricMean()

Returns the geometric mean of all the aggregated data.

Returns:double

the geometric mean

See Also
SummaryStatistics#getGeometricMean()
getMaxback to summary
public double getMax()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getMax.

Doc from org.apache.commons.math3.stat.descriptive.StatisticalSummary.getMax.

Returns the maximum of the available values. This version returns the maximum over all the aggregated data.

Returns:double

The max or Double.NaN if no values have been added.

See Also
StatisticalSummary#getMax()
getMeanback to summary
public double getMean()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getMean.

Doc from org.apache.commons.math3.stat.descriptive.StatisticalSummary.getMean.

Returns the arithmetic mean of the available values. This version returns the mean of all the aggregated data.

Returns:double

The mean or Double.NaN if no values have been added.

See Also
StatisticalSummary#getMean()
getMinback to summary
public double getMin()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getMin.

Doc from org.apache.commons.math3.stat.descriptive.StatisticalSummary.getMin.

Returns the minimum of the available values. This version returns the minimum over all the aggregated data.

Returns:double

The min or Double.NaN if no values have been added.

See Also
StatisticalSummary#getMin()
getNback to summary
public long getN()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getN.

Doc from org.apache.commons.math3.stat.descriptive.StatisticalSummary.getN.

Returns the number of available values. This version returns a count of all the aggregated data.

Returns:long

The number of available values

See Also
StatisticalSummary#getN()
getSecondMomentback to summary
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:double

second central moment statistic

See Also
SummaryStatistics#getSecondMoment()
getStandardDeviationback to summary
public double getStandardDeviation()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getStandardDeviation.

Doc from org.apache.commons.math3.stat.descriptive.StatisticalSummary.getStandardDeviation.

Returns the standard deviation of the available values.. This version returns the standard deviation of all the aggregated data.

Returns:double

The standard deviation, Double.NaN if no values have been added or 0.0 for a single value set.

See Also
StatisticalSummary#getStandardDeviation()
getSumback to summary
public double getSum()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getSum.

Doc from org.apache.commons.math3.stat.descriptive.StatisticalSummary.getSum.

Returns the sum of the values that have been added to Univariate.. This version returns a sum of all the aggregated data.

Returns:double

The sum or Double.NaN if no values have been added

See Also
StatisticalSummary#getSum()
getSummaryback to summary
public StatisticalSummary getSummary()

Return a StatisticalSummaryValues instance reporting current aggregate statistics.

Returns:StatisticalSummary

Current values of aggregate statistics

getSumOfLogsback to summary
public double getSumOfLogs()

Returns the sum of the logs of all the aggregated data.

Returns:double

the sum of logs

See Also
SummaryStatistics#getSumOfLogs()
getSumsqback to summary
public double getSumsq()

Returns the sum of the squares of all the aggregated data.

Returns:double

The sum of squares

See Also
SummaryStatistics#getSumsq()
getVarianceback to summary
public double getVariance()

Implements org.apache.commons.math3.stat.descriptive.StatisticalSummary.getVariance.

Doc from org.apache.commons.math3.stat.descriptive.StatisticalSummary.getVariance.

Returns the variance of the available values.. This version returns the variance of all the aggregated data.

Returns:double

The variance, Double.NaN if no values have been added or 0.0 for a single value set.

See Also
StatisticalSummary#getVariance()
org.apache.commons.math3.stat.descriptive back to summary

private Class AggregateSummaryStatistics.AggregatingSummaryStatistics

extends SummaryStatistics
Class Inheritance

A SummaryStatistics that also forwards all values added to it to a second SummaryStatistics for aggregation.
Since
2.0

Field Summary

Modifier and TypeField and Description
private final SummaryStatistics
aggregateStatistics

An additional SummaryStatistics into which values added to these statistics (and possibly others) are aggregated

private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
AggregatingSummaryStatistics(SummaryStatistics
a SummaryStatistics into which values added to this statistics object should be aggregated
aggregateStatistics
)

Initializes a new AggregatingSummaryStatistics with the specified aggregate statistics object

Method Summary

Modifier and TypeMethod and Description
public void
addValue(double
the value to add
value
)

Overrides org.apache.commons.math3.stat.descriptive.SummaryStatistics.addValue.

Add a value to the data.

public boolean

Returns:

true if object equals this
equals
(Object
the object to test equality against.
object
)

Overrides org.apache.commons.math3.stat.descriptive.SummaryStatistics.equals.

Returns true iff object is a SummaryStatistics instance and all statistics have the same values as this.

public int

Returns:

hash code
hashCode
()

Overrides org.apache.commons.math3.stat.descriptive.SummaryStatistics.hashCode.

Returns hash code based on values of statistics

Inherited from org.apache.commons.math3.stat.descriptive.SummaryStatistics:
clearcopycopygetGeoMeanImplgetGeometricMeangetMaxgetMaxImplgetMeangetMeanImplgetMingetMinImplgetNgetPopulationVariancegetQuadraticMeangetSecondMomentgetStandardDeviationgetSumgetSumImplgetSumLogImplgetSummarygetSumOfLogsgetSumsqgetSumsqImplgetVariancegetVarianceImplsetGeoMeanImplsetMaxImplsetMeanImplsetMinImplsetSumImplsetSumLogImplsetSumsqImplsetVarianceImpltoString

Field Detail

aggregateStatisticsback to summary
private final SummaryStatistics aggregateStatistics

An additional SummaryStatistics into which values added to these statistics (and possibly others) are aggregated

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.math3.stat.descriptive.SummaryStatistics.serialVersionUID.

The serialization version of this class

Constructor Detail

AggregatingSummaryStatisticsback to summary
pack-priv AggregatingSummaryStatistics(SummaryStatistics aggregateStatistics)

Initializes a new AggregatingSummaryStatistics with the specified aggregate statistics object

Parameters
aggregateStatistics:SummaryStatistics

a SummaryStatistics into which values added to this statistics object should be aggregated

Method Detail

addValueback to summary
public void addValue(double value)

Overrides org.apache.commons.math3.stat.descriptive.SummaryStatistics.addValue.

Doc from org.apache.commons.math3.stat.descriptive.SummaryStatistics.addValue.

Add a value to the data. This version adds the provided value to the configured aggregate after adding it to these statistics.

Parameters
value:double

the value to add

Annotations
@Override
See Also
SummaryStatistics#addValue(double)
equalsback to summary
public boolean equals(Object object)

Overrides org.apache.commons.math3.stat.descriptive.SummaryStatistics.equals.

Returns true iff object is a SummaryStatistics instance and all statistics have the same values as this.

Parameters
object:Object

the object to test equality against.

Returns:boolean

true if object equals this

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides org.apache.commons.math3.stat.descriptive.SummaryStatistics.hashCode.

Returns hash code based on values of statistics

Returns:int

hash code

Annotations
@Override