Computes the arithmetic mean of a set of values. Uses the definitional formula:
mean = sum(x_i) / n
where n is the number of observations.
When increment(double) is used to add data incrementally from a
stream of (unstored) values, the value of the statistic that
getResult() returns is computed using the following recursive
updating algorithm:
m = the first valuem = m + (new value - m) / (number of observations) If evaluate(double[]) is used to compute the mean of an array
of stored values, a two-pass, corrected algorithm is used, starting with
the definitional formula computed using the array of stored values and then
correcting this by adding the mean deviation of the data values from the
arithmetic mean. See, e.g. "Comparison of Several Algorithms for Computing
Sample Means and Variances," Robert F. Ling, Journal of the American
Statistical Association, Vol. 69, No. 348 (Dec., 1974), pp. 859-866.
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.
increment() or
clear() method, it must be synchronized externally.
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | incMoment
Determines whether or not this statistic can be incremented or cleared. |
| protected FirstMoment | moment
First moment on which this statistic is based. |
| private static final long | serialVersionUID
Serializable version identifier |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements abstract org. Implements org. Clears the internal state of the Statistic |
| public Mean | copy()
Implements abstract org. Implements org. Returns a copy of the statistic with the same internal state. |
| public static void | |
| public double | Returns: the mean of the values or Double.NaN 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. Returns the arithmetic mean of the entries in the specified portion of
the input array, or |
| public double | Returns: the mean of the values or Double.NaN 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)Implements org. Returns the weighted arithmetic mean of the entries in the specified portion of
the input array, or |
| public double | Returns: the mean of the values or Double.NaN if length = 0the input array values, final double[] the weights array weights)Implements org. Returns the weighted arithmetic mean of the entries in 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. |
| incMoment | back to summary |
|---|---|
| protected boolean incMoment Determines whether or not this statistic can be incremented or cleared. Statistics based on (constructed from) external moments cannot be incremented or cleared. | |
| moment | back to summary |
|---|---|
| protected FirstMoment moment First moment on which this statistic is based. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable version identifier | |
| Mean | back to summary |
|---|---|
| public Mean() Constructs a Mean. | |
| Mean | back to summary |
|---|---|
| public Mean(final FirstMoment m1) Constructs a Mean with an External Moment.
| |
| Mean | back to summary |
|---|---|
| public Mean(Mean 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 Mean 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(Mean source, Mean 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. Returns the arithmetic mean of the entries in the specified portion of
the input array, or
Throws
See
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final double[] weights, final int begin, final int length) throws MathIllegalArgumentException Implements org. Returns the weighted arithmetic mean of the entries in the specified portion of
the input array, or
Throws
See
Throws
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final double[] weights) throws MathIllegalArgumentException Implements org. Returns the weighted arithmetic mean of the entries in the input array.
Throws
See
Throws
| |
| 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. Note that when
| |