|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math.stat.univariate.AbstractUnivariateStatistic org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic commonSense.stat.basic.Mean
Returns the arithmetic mean of the available values. Uses the definitional formula:
mean = sum(x_i) / n
where n
is the number of observations.
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 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.
Field Summary | |
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. |
Constructor Summary | |
Mean()
Constructs a Mean. |
|
Mean(FirstMoment m1)
Constructs a Mean with an External Moment. |
Method Summary | |
void |
clear()
|
double |
evaluate(double[] values,
int begin,
int length)
Returns the arithmetic mean of the entries in the specified portion of the input array, or Double.NaN if the designated subarray
is empty.
|
long |
getN()
|
double |
getResult()
|
void |
increment(double d)
|
Methods inherited from class org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatistic |
equals, evaluate, hashCode, incrementAll, incrementAll |
Methods inherited from class org.apache.commons.math.stat.univariate.AbstractUnivariateStatistic |
test |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected FirstMoment moment
protected boolean incMoment
Statistics based on (constructed from) external moments cannot be incremented or cleared.
Constructor Detail |
public Mean()
public Mean(FirstMoment m1)
m1
- the momentMethod Detail |
public void increment(double d)
increment
in interface org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic
StorelessUnivariateStatistic.increment(double)
public void clear()
clear
in interface org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic
StorelessUnivariateStatistic.clear()
public double getResult()
getResult
in interface org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic
StorelessUnivariateStatistic.getResult()
public long getN()
getN
in interface org.apache.commons.math.stat.univariate.StorelessUnivariateStatistic
StorelessUnivariateStatistic.getN()
public double evaluate(double[] values, int begin, int length)
Double.NaN
if the designated subarray
is empty.
Throws IllegalArgumentException
if the array is null.
See Mean
for details on the computing algorithm.
evaluate
in interface org.apache.commons.math.stat.univariate.UnivariateStatistic
values
- the input arraybegin
- index of the first array element to includelength
- the number of elements to include
java.lang.IllegalArgumentException
- if the array is null or the array index
parameters are not valid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |