commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Warren Tang (Created) (JIRA)" <>
Subject [jira] [Created] (MATH-691) Statistics.setVarianceImpl makes getStandardDeviation produce NaN
Date Sun, 16 Oct 2011 17:20:13 GMT
Statistics.setVarianceImpl makes getStandardDeviation produce NaN

                 Key: MATH-691
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 2.2
         Environment: Windows 7 64-bit, java version 1.6.0_23
            Reporter: Warren Tang
            Priority: Minor

Invoking SummaryStatistics.setVarianceImpl(new Variance(true/false) makes getStandardDeviation
produce NaN. The code to reproduce it:

    int[] scores = {1, 2, 3, 4};
    SummaryStatistics stats = new SummaryStatistics();
    stats.setVarianceImpl(new Variance(false)); //use "population variance"
    for(int i : scores) {
    double sd = stats.getStandardDeviation();

A workaround is:
    double sd = FastMath.sqrt(stats.getSecondMoment() / stats.getN());
as suggested by Mikkel.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message