Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 50603 invoked from network); 13 Dec 2010 00:44:20 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Dec 2010 00:44:20 -0000 Received: (qmail 61194 invoked by uid 500); 13 Dec 2010 00:44:19 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 61144 invoked by uid 500); 13 Dec 2010 00:44:19 -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 61137 invoked by uid 99); 13 Dec 2010 00:44:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Dec 2010 00:44:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Mon, 13 Dec 2010 00:44:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4398323889FD; Mon, 13 Dec 2010 00:43:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1044981 - in /commons/proper/math: branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/ branches/MATH_2_X/src/site/xdoc/ branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/ trunk/src/main/java/org/apache/commons/math/sta... Date: Mon, 13 Dec 2010 00:43:58 -0000 To: commits@commons.apache.org From: psteitz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101213004358.4398323889FD@eris.apache.org> Author: psteitz Date: Mon Dec 13 00:43:57 2010 New Revision: 1044981 URL: http://svn.apache.org/viewvc?rev=1044981&view=rev Log: Added a getUniqueCount() method to Frequency to return the number of unique values included in the frequency table. Reported and patched by Patrick Meyer JIRA: MATH-414 Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/Frequency.java commons/proper/math/branches/MATH_2_X/src/site/xdoc/changes.xml commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/FrequencyTest.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/Frequency.java commons/proper/math/trunk/src/site/xdoc/changes.xml commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/Frequency.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/Frequency.java?rev=1044981&r1=1044980&r2=1044981&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/Frequency.java (original) +++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/stat/Frequency.java Mon Dec 13 00:43:57 2010 @@ -287,6 +287,16 @@ public class Frequency implements Serial public long getCount(char v) { return getCount(Character.valueOf(v)); } + + /** + * Returns the number of values in the frequency table. + * + * @return the number of unique values that have been added to the frequency table. + * @see #valuesIterator() + */ + public int getUniqueCount(){ + return freqTable.keySet().size(); + } //------------------------------------------------------------- Modified: commons/proper/math/branches/MATH_2_X/src/site/xdoc/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/site/xdoc/changes.xml?rev=1044981&r1=1044980&r2=1044981&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/site/xdoc/changes.xml (original) +++ commons/proper/math/branches/MATH_2_X/src/site/xdoc/changes.xml Mon Dec 13 00:43:57 2010 @@ -52,6 +52,10 @@ The type attribute can be add,u If the output is not quite correct, check for invisible trailing spaces! --> + + Added a getUniqueCount() method to Frequency to return the number of unique + values included in the frequency table. + Modified NormalDistributionImpl.cumulativeProbability to return 0 or 1, respectively for values more than 40 standard deviations from the mean. Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/FrequencyTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/FrequencyTest.java?rev=1044981&r1=1044980&r2=1044981&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/FrequencyTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/stat/FrequencyTest.java Mon Dec 13 00:43:57 2010 @@ -273,5 +273,15 @@ public final class FrequencyTest extends f.addValue(twoI); assertEquals(f, TestUtils.serializeAndRecover(f)); } + + public void testGetUniqueCount() { + assertEquals(0, f.getUniqueCount()); + f.addValue(oneL); + assertEquals(1, f.getUniqueCount()); + f.addValue(oneL); + assertEquals(1, f.getUniqueCount()); + f.addValue(twoI); + assertEquals(2, f.getUniqueCount()); + } } Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/Frequency.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/Frequency.java?rev=1044981&r1=1044980&r2=1044981&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/Frequency.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/Frequency.java Mon Dec 13 00:43:57 2010 @@ -241,7 +241,15 @@ public class Frequency implements Serial return getCount(Character.valueOf(v)); } - //------------------------------------------------------------- + /** + * Returns the number of values in the frequency table. + * + * @return the number of unique values that have been added to the frequency table. + * @see #valuesIterator() + */ + public int getUniqueCount(){ + return freqTable.keySet().size(); + } /** * Returns the percentage of values that are equal to v Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=1044981&r1=1044980&r2=1044981&view=diff ============================================================================== --- commons/proper/math/trunk/src/site/xdoc/changes.xml (original) +++ commons/proper/math/trunk/src/site/xdoc/changes.xml Mon Dec 13 00:43:57 2010 @@ -134,6 +134,10 @@ The type attribute can be add,u + + Added a getUniqueCount() method to Frequency to return the number of unique + values included in the frequency table. + Modified NormalDistributionImpl.cumulativeProbability to return 0 or 1, respectively for values more than 40 standard deviations from the mean. Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java?rev=1044981&r1=1044980&r2=1044981&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java Mon Dec 13 00:43:57 2010 @@ -251,5 +251,15 @@ public final class FrequencyTest extends f.addValue(twoI); assertEquals(f, TestUtils.serializeAndRecover(f)); } + + public void testGetUniqueCount() { + assertEquals(0, f.getUniqueCount()); + f.addValue(oneL); + assertEquals(1, f.getUniqueCount()); + f.addValue(oneL); + assertEquals(1, f.getUniqueCount()); + f.addValue(twoI); + assertEquals(2, f.getUniqueCount()); + } }