Added missing method for computing variance from mean with no subarray specified.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141375 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
af2937a3ee
commit
e3c0133202
|
@ -38,7 +38,7 @@ import org.apache.commons.math.stat.univariate.AbstractStorelessUnivariateStatis
|
|||
* one of the threads invokes the <code>increment()</code> or
|
||||
* <code>clear()</code> method, it must be synchronized externally.
|
||||
*
|
||||
* @version $Revision: 1.25 $ $Date: 2004/07/10 17:09:08 $
|
||||
* @version $Revision: 1.26 $ $Date: 2004/07/11 18:38:12 $
|
||||
*/
|
||||
public class Variance extends AbstractStorelessUnivariateStatistic implements Serializable {
|
||||
|
||||
|
@ -211,5 +211,30 @@ public class Variance extends AbstractStorelessUnivariateStatistic implements Se
|
|||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the variance of the entries in the input array, using the
|
||||
* precomputed mean value. Returns <code>Double.NaN</code> if the array
|
||||
* is empty.
|
||||
* <p>
|
||||
* See {@link Variance} for details on the computing algorithm.
|
||||
* <p>
|
||||
* Returns 0 for a single-value (i.e. length = 1) sample.
|
||||
* <p>
|
||||
* Throws <code>IllegalArgumentException</code> if the array is null.
|
||||
* <p>
|
||||
* Does not change the internal state of the statistic.
|
||||
*
|
||||
* @param values the input array
|
||||
* @param mean the precomputed mean value
|
||||
* @return the variance of the values or Double.NaN if the array is empty
|
||||
* @throws IllegalArgumentException if the array is null
|
||||
*/
|
||||
public double evaluate(final double[] values, final double mean) {
|
||||
if (values == null) {
|
||||
throw new IllegalArgumentException("input values array is null");
|
||||
}
|
||||
return evaluate(values, mean, 0, values.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue