Class VarPAggregator<V extends Number>
- All Implemented Interfaces:
Externalizable, Serializable, Aggregator<V, Double, VarPAggregator<V>>
- Direct Known Subclasses:
StdDevPAggregator, VarSAggregator
This class implements the SQL Standard VAR_POP() aggregator, computing a population's variance. It uses the IBM formula described here:
sum(xi2)/n - m2 where n is the number of items in the population m is the population average x1 ... xn are the items in the population
The IBM formula can be computed without buffering up an arbitrarily long list of items. The IBM formula is algebraically equivalent to the textbook formula for population variance:
sum( (xi - m)2 )/n
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprivate static final longprotected VarPAggregator.Sums -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccumulate(V value) Accumulate the next scalar valueprotected Doublevoidinit()Initialize the Aggregatorvoidmerge(VarPAggregator<V> otherAggregator) For merging another partial result into this Aggregator.voidReturn the result scalar valuevoid
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
sums
-
count
protected int count
-
-
Constructor Details
-
VarPAggregator
public VarPAggregator()
-
-
Method Details
-
init
public void init()Description copied from interface:AggregatorInitialize the Aggregator- Specified by:
initin interfaceAggregator<V extends Number, Double, VarPAggregator<V extends Number>>
-
accumulate
Description copied from interface:AggregatorAccumulate the next scalar value- Specified by:
accumulatein interfaceAggregator<V extends Number, Double, VarPAggregator<V extends Number>>
-
merge
Description copied from interface:AggregatorFor merging another partial result into this Aggregator. This lets the SQL interpreter divide the incoming rows into subsets, aggregating each subset in isolation, and then merging the partial results together. This method can be called when performing a grouped aggregation with a large number of groups. While processing such a query, Derby may write intermediate grouped results to disk. The intermediate results may be retrieved and merged with later results if Derby encounters later rows which belong to groups whose intermediate results have been written to disk. This situation can occur with a query like the following:
select a, mode( b ) from mode_inputs group by a order by a
- Specified by:
mergein interfaceAggregator<V extends Number, Double, VarPAggregator<V extends Number>>
-
computeVar
-
terminate
Description copied from interface:AggregatorReturn the result scalar value- Specified by:
terminatein interfaceAggregator<V extends Number, Double, VarPAggregator<V extends Number>>
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-