If there are no values in the dataset, then 0 is returned.
If any of the values are
NaN, then NaN is returned.
Note that this implementation is not synchronized. If
multiple threads access an instance of this class concurrently, and at least
one of the threads invokes the increment() or
clear() method, it must be synchronized externally.
| Modifier and Type | Field and Description |
|---|---|
| private long | |
| private static final long | serialVersionUID
Serializable version identifier |
| private double | value
The currently running sum. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements abstract org. Implements org. Clears the internal state of the Statistic |
| public Sum | copy()
Implements abstract org. Implements org. Returns a copy of the statistic with the same internal state. |
| public static void | |
| public double | Returns: the sum of the values or 0 if length = 0the input array values, final int index of the first array element to include begin, final int the number of elements to include length)Overrides org. Implements org. The sum of the entries in the specified portion of the input array, or 0 if the designated subarray is empty. |
| public double | Returns: the sum of the values or 0 if length = 0the input array values, final double[] the weights array weights, final int index of the first array element to include begin, final int the number of elements to include length)The weighted sum of the entries in the specified portion of the input array, or 0 if the designated subarray is empty. |
| public double | Returns: the sum of the values or Double.NaN if length = 0the input array values, final double[] the weights array weights)The weighted sum of the entries in the the input array. |
| public long | getN()
Implements org. Returns the number of values that have been added. |
| public double | getResult()
Implements abstract org. Implements org. Returns the current value of the Statistic. |
| public void | increment(final double
the new value. d)Implements abstract org. Implements org. Updates the internal state of the statistic to reflect the addition of the new value. |
| n | back to summary |
|---|---|
| private long n | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable version identifier | |
| value | back to summary |
|---|---|
| private double value The currently running sum. | |
| Sum | back to summary |
|---|---|
| public Sum() Create a Sum instance | |
| Sum | back to summary |
|---|---|
| public Sum(Sum original) throws NullArgumentException Copy constructor, creates a new
| |
| clear | back to summary |
|---|---|
| public void clear() Implements abstract org. Implements org. Doc from org. Clears the internal state of the Statistic
| |
| copy | back to summary |
|---|---|
| public Sum copy() Implements abstract org. Implements org. Doc from org. Returns a copy of the statistic with the same internal state.
| |
| copy | back to summary |
|---|---|
| public static void copy(Sum source, Sum dest) throws NullArgumentException Copies source to dest. Neither source nor dest can be null.
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final int begin, final int length) throws MathIllegalArgumentException Overrides org. Implements org. The sum of the entries in the specified portion of the input array, or 0 if the designated subarray is empty.
Throws
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final double[] weights, final int begin, final int length) throws MathIllegalArgumentException The weighted sum of the entries in the specified portion of the input array, or 0 if the designated subarray is empty.
Throws
Uses the formula, weighted sum = Σ(values[i] * weights[i])
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final double[] weights) throws MathIllegalArgumentException The weighted sum of the entries in the the input array.
Throws
Uses the formula, weighted sum = Σ(values[i] * weights[i])
| |
| getN | back to summary |
|---|---|
| public long getN() Implements org. Doc from org. Returns the number of values that have been added.
| |
| getResult | back to summary |
|---|---|
| public double getResult() Implements abstract org. Implements org. Doc from org. Returns the current value of the Statistic.
| |
| increment | back to summary |
|---|---|
| public void increment(final double d) Implements abstract org. Implements org. Doc from org. Updates the internal state of the statistic to reflect the addition of the new value.
| |