The following recursive updating formula is used:
Let
new value = old value + dev^2 * (n -1) / n.
Returns Double.NaN if no data values have been added and
returns 0 if there is just one value in the data set.
Note that Double.NaN may also be returned if the input includes NaN
and / or infinite values.
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 |
|---|---|
| protected double | m2
second moment of values that have been added |
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SecondMoment(SecondMoment
the original)SecondMoment instance to copyCopy constructor, creates a new |
| m2 | back to summary |
|---|---|
| protected double m2 second moment of values that have been added | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serializable version identifier | |
| SecondMoment | back to summary |
|---|---|
| public SecondMoment() Create a SecondMoment instance | |
| SecondMoment | back to summary |
|---|---|
| public SecondMoment(SecondMoment original) throws NullArgumentException Copy constructor, creates a new
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides org. Implements org. Doc from org. Clears the internal state of the Statistic
| |
| copy | back to summary |
|---|---|
| public SecondMoment copy() Overrides 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(SecondMoment source, SecondMoment dest) throws NullArgumentException Copies source to dest. Neither source nor dest can be null.
| |
| getResult | back to summary |
|---|---|
| public double getResult() Overrides org. Implements org. Doc from org. Returns the current value of the Statistic.
| |
| increment | back to summary |
|---|---|
| public void increment(final double d) Overrides org. Implements org. Doc from org. Updates the internal state of the statistic to reflect the addition of the new value.
| |