From issues-return-23122-apmail-commons-issues-archive=commons.apache.org@commons.apache.org Sun Nov 27 05:23:13 2011 Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E840E7599 for ; Sun, 27 Nov 2011 05:23:12 +0000 (UTC) Received: (qmail 58510 invoked by uid 500); 27 Nov 2011 05:23:10 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 58136 invoked by uid 500); 27 Nov 2011 05:23:08 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 58105 invoked by uid 99); 27 Nov 2011 05:23:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Nov 2011 05:23:05 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Nov 2011 05:23:02 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 8D8F1A1578 for ; Sun, 27 Nov 2011 05:22:41 +0000 (UTC) Date: Sun, 27 Nov 2011 05:22:41 +0000 (UTC) From: "Phil Steitz (Resolved) (JIRA)" To: issues@commons.apache.org Message-ID: <271968424.14354.1322371361593.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <92814258.18553.1318785613742.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (MATH-691) Statistics.setVarianceImpl makes getStandardDeviation produce NaN MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-691?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Phil Steitz resolved MATH-691. ------------------------------ Resolution: Fixed Fixed in r1206666. > Statistics.setVarianceImpl makes getStandardDeviation produce NaN > ----------------------------------------------------------------- > > Key: MATH-691 > URL: https://issues.apache.org/jira/browse/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 > Assignee: Phil Steitz > Priority: Minor > Fix For: 3.0 > > Original Estimate: 5h > Remaining Estimate: 5h > > Invoking SummaryStatistics.setVarianceImpl(new Variance(true/false) makes getStandardDeviation produce NaN. The code to reproduce it: > {code:java} > int[] scores = {1, 2, 3, 4}; > SummaryStatistics stats = new SummaryStatistics(); > stats.setVarianceImpl(new Variance(false)); //use "population variance" > for(int i : scores) { > stats.addValue(i); > } > double sd = stats.getStandardDeviation(); > System.out.println(sd); > {code} > A workaround suggested by Mikkel is: > {code:java} > double sd = FastMath.sqrt(stats.getSecondMoment() / stats.getN()); > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira