mean = sum(x_i) / n
where n is the number of observations.
To limit numeric errors, the value of the statistic is computed using the following recursive updating algorithm:
m = the first valuem = m + (new value - m) / (number of observations)
Returns Double.NaN if the dataset is empty. 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 | dev
Deviation of most recently added value from previous first moment. |
| protected double | m1
First moment of values that have been added |
| protected long | n
Count of values that have been added |
| protected double | nDev
Deviation of most recently added value from previous first moment, normalized by previous sample size. |
| private static final long | serialVersionUID
Serializable version identifier |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv | FirstMoment(FirstMoment
the original)FirstMoment instance to copyCopy constructor, creates a new |
| dev | back to summary |
|---|---|
| protected double dev Deviation of most recently added value from previous first moment. Retained to prevent repeated computation in higher order moments. | |
| m1 | back to summary |
|---|---|
| protected double m1 First moment of values that have been added | |
| n | back to summary |
|---|---|
| protected long n Count of values that have been added | |
| nDev | back to summary |
|---|---|
| protected double nDev Deviation of most recently added value from previous first moment, normalized by previous sample size. Retained to prevent repeated computation in higher order moments | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable version identifier | |
| FirstMoment | back to summary |
|---|---|
| pack-priv FirstMoment() Create a FirstMoment instance | |
| FirstMoment | back to summary |
|---|---|
| pack-priv FirstMoment(FirstMoment 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 FirstMoment 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(FirstMoment source, FirstMoment dest) throws NullArgumentException Copies source to dest. Neither source nor dest can be null.
| |
| 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.
| |