Made assumption about precomputed mean explicit in javadoc. Added missing method.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141437 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2004-09-01 15:54:39 +00:00
parent 45fe7d2981
commit 3f5862a60e
1 changed files with 32 additions and 1 deletions

View File

@ -30,7 +30,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.22 $ $Date: 2004/07/18 04:42:02 $
* @version $Revision: 1.23 $ $Date: 2004/09/01 15:54:39 $
*/
public class StandardDeviation extends AbstractStorelessUnivariateStatistic
implements Serializable {
@ -133,6 +133,11 @@ public class StandardDeviation extends AbstractStorelessUnivariateStatistic
* <p>
* Returns 0 for a single-value (i.e. length = 1) sample.
* <p>
* The formula used assumes that the supplied mean value is the arithmetic
* mean of the sample data, not a known population parameter. This method
* is supplied only to save computation when the mean has already been
* computed.
* <p>
* Throws <code>IllegalArgumentException</code> if the array is null.
* <p>
* Does not change the internal state of the statistic.
@ -149,4 +154,30 @@ public class StandardDeviation extends AbstractStorelessUnivariateStatistic
final int begin, final int length) {
return Math.sqrt(variance.evaluate(values, mean, begin, length));
}
/**
* Returns the Standard Deviation of the entries in the input array, using
* the precomputed mean value. Returns
* <code>Double.NaN</code> if the designated subarray is empty.
* <p>
* Returns 0 for a single-value (i.e. length = 1) sample.
* <p>
* The formula used assumes that the supplied mean value is the arithmetic
* mean of the sample data, not a known population parameter. This method
* is supplied only to save computation when the mean has already been
* computed.
* <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 standard deviation of the values or Double.NaN if length = 0
* @throws IllegalArgumentException if the array is null or the array index
* parameters are not valid
*/
public double evaluate(final double[] values, final double mean) {
return Math.sqrt(variance.evaluate(values, mean));
}
}