Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AECDE9F08 for ; Fri, 8 Jun 2012 11:04:37 +0000 (UTC) Received: (qmail 35773 invoked by uid 500); 8 Jun 2012 11:04:36 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 35390 invoked by uid 500); 8 Jun 2012 11:04:34 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 35358 invoked by uid 99); 8 Jun 2012 11:04:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 11:04:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 11:04:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E492D238899C for ; Fri, 8 Jun 2012 11:04:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1348024 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java test/java/org/apache/commons/math3/stat/inference/MannWhitneyUTestTest.java Date: Fri, 08 Jun 2012 11:04:11 -0000 To: commits@commons.apache.org From: mikl@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120608110411.E492D238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikl Date: Fri Jun 8 11:04:11 2012 New Revision: 1348024 URL: http://svn.apache.org/viewvc?rev=1348024&view=rev Log: MATH-790: Patch applied to fix the overflow issue. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java commons/proper/math/trunk/src/test/java/org/apache/commons/math3/stat/inference/MannWhitneyUTestTest.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java?rev=1348024&r1=1348023&r2=1348024&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java Fri Jun 8 11:04:11 2012 @@ -170,11 +170,11 @@ public class MannWhitneyUTest { final int n2) throws ConvergenceException, MaxCountExceededException { - final int n1n2prod = n1 * n2; + final double n1n2prod = n1 * n2; // http://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U#Normal_approximation - final double EU = (double) n1n2prod / 2.0; - final double VarU = (double) (n1n2prod * (n1 + n2 + 1)) / 12.0; + final double EU = n1n2prod / 2.0; + final double VarU = n1n2prod * (n1 + n2 + 1) / 12.0; final double z = (Umin - EU) / FastMath.sqrt(VarU); Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/stat/inference/MannWhitneyUTestTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/stat/inference/MannWhitneyUTestTest.java?rev=1348024&r1=1348023&r2=1348024&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/stat/inference/MannWhitneyUTestTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/stat/inference/MannWhitneyUTestTest.java Fri Jun 8 11:04:11 2012 @@ -100,4 +100,16 @@ public class MannWhitneyUTestTest { // expected } } + + @Test + public void testBigDataSet() throws Exception { + double[] d1 = new double[1500]; + double[] d2 = new double[1500]; + for (int i = 0; i < 1500; i++) { + d1[i] = 2 * i; + d2[i] = 2 * i + 1; + } + double result = testStatistic.mannWhitneyUTest(d1, d2); + Assert.assertTrue(result > 0.1); + } }