Made it clear that NaNs or infinities may yield NaN in moment computations. JIRA: MATH-1146.

This commit is contained in:
Phil Steitz 2014-12-16 16:49:16 -07:00
parent d9b951c1fa
commit 26e6114583
4 changed files with 11 additions and 4 deletions

View File

@ -36,7 +36,9 @@ import org.apache.commons.math3.util.MathUtils;
* {@link StandardDeviation}</p> * {@link StandardDeviation}</p>
* <p> * <p>
* Note that this statistic is undefined for n < 4. <code>Double.Nan</code> * Note that this statistic is undefined for n < 4. <code>Double.Nan</code>
* is returned when there is not sufficient data to compute the statistic.</p> * is returned when there is not sufficient data to compute the statistic.
* Note that Double.NaN may also be returned if the input includes NaN
* and / or infinite values.</p>
* <p> * <p>
* <strong>Note that this implementation is not synchronized.</strong> If * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least * multiple threads access an instance of this class concurrently, and at least

View File

@ -50,7 +50,9 @@ import org.apache.commons.math3.util.MathUtils;
* Sample Means and Variances," Robert F. Ling, Journal of the American * Sample Means and Variances," Robert F. Ling, Journal of the American
* Statistical Association, Vol. 69, No. 348 (Dec., 1974), pp. 859-866. </p> * Statistical Association, Vol. 69, No. 348 (Dec., 1974), pp. 859-866. </p>
* <p> * <p>
* Returns <code>Double.NaN</code> if the dataset is empty. * Returns <code>Double.NaN</code> if the dataset is empty. Note that
* Double.NaN may also be returned if the input includes NaN and / or infinite
* values.
* </p> * </p>
* <strong>Note that this implementation is not synchronized.</strong> If * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least * multiple threads access an instance of this class concurrently, and at least

View File

@ -38,7 +38,9 @@ import org.apache.commons.math3.util.MathUtils;
* new value = old value - 3 * (dev/n) * m2 + (n-1) * (n -2) * (dev^3/n^2)</p> * new value = old value - 3 * (dev/n) * m2 + (n-1) * (n -2) * (dev^3/n^2)</p>
* <p> * <p>
* Returns <code>Double.NaN</code> if no data values have been added and * Returns <code>Double.NaN</code> if no data values have been added and
* returns <code>0</code> if there is just one value in the data set.</p> * returns <code>0</code> if there is just one value in the data set.
* Note that Double.NaN may also be returned if the input includes NaN
* and / or infinite values.</p>
* <p> * <p>
* <strong>Note that this implementation is not synchronized.</strong> If * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least * multiple threads access an instance of this class concurrently, and at least

View File

@ -234,7 +234,8 @@ public class Variance extends AbstractStorelessUnivariateStatistic implements Se
/** /**
* Returns the variance of the entries in the specified portion of * Returns the variance of the entries in the specified portion of
* the input array, or <code>Double.NaN</code> if the designated subarray * the input array, or <code>Double.NaN</code> if the designated subarray
* is empty. * is empty. Note that Double.NaN may also be returned if the input
* includes NaN and / or infinite values.
* <p> * <p>
* See {@link Variance} for details on the computing algorithm.</p> * See {@link Variance} for details on the computing algorithm.</p>
* <p> * <p>