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
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| protected int | |
| private static final long | |
| protected VarPAggregator. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | accumulate(V
The new value to accumulate. value)Implements org. Accumulate the next scalar value |
| protected Double | |
| public void | |
| public void | merge(VarPAggregator<V>
The other Aggregator to merge with otherAggregator)Implements org. For merging another partial result into this Aggregator. |
| public void | readExternal(ObjectInput
the stream to read data from in order to restore the object in)Implements java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. |
| public Double | |
| public void | writeExternal(ObjectOutput
the stream to write the object to out)Implements java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays. |
| count | back to summary |
|---|---|
| protected int count | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| sums | back to summary |
|---|---|
| protected VarPAggregator. | |
| VarPAggregator | back to summary |
|---|---|
| public VarPAggregator() | |
| accumulate | back to summary |
|---|---|
| public void accumulate(V value) Implements org. Doc from org. Accumulate the next scalar value
| |
| computeVar | back to summary |
|---|---|
| protected Double computeVar() | |
| init | back to summary |
|---|---|
| public void init() Implements org. Doc from org. Initialize the Aggregator
| |
| merge | back to summary |
|---|---|
| public void merge(VarPAggregator<V> otherAggregator) Implements org. Doc from org. For 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
| |
| readExternal | back to summary |
|---|---|
| public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException Implements java. Doc from java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
| |
| terminate | back to summary |
|---|---|
| public Double terminate() Implements org. Doc from org. Return the result scalar value | |
| writeExternal | back to summary |
|---|---|
| public void writeExternal(ObjectOutput out) throws IOException Implements java. Doc from java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Sums | back to summary |
|---|---|
| public Sums() | |