commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r831510 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/random/RandomDataImpl.java site/xdoc/changes.xml test/java/org/apache/commons/math/random/RandomDataTest.java
Date Sat, 31 Oct 2009 02:30:18 GMT
Author: psteitz
Date: Sat Oct 31 02:30:18 2009
New Revision: 831510

URL: http://svn.apache.org/viewvc?rev=831510&view=rev
Log:
Fixed parameter test in RandomDataImpl#nextExponential. JIRA: MATH-309.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java?rev=831510&r1=831509&r2=831510&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
Sat Oct 31 02:30:18 2009
@@ -457,12 +457,11 @@
      * uniform deviates.
      * </p>
      *
-     * @param mean
-     *            the mean of the distribution
+     * @param mean the mean of the distribution
      * @return the random Exponential value
      */
     public double nextExponential(double mean) {
-        if (mean < 0.0) {
+        if (mean <= 0.0) {
             throw MathRuntimeException.createIllegalArgumentException(
                   "mean must be positive ({0})", mean);
         }

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=831510&r1=831509&r2=831510&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Sat Oct 31 02:30:18 2009
@@ -39,6 +39,10 @@
   </properties>
   <body>
     <release version="2.1" date="TBD" description="TBD">
+      <action dev="psteitz" type="fix" issue="MATH-309" due-to="Mikkel Meyer Andersen">
+        Fixed parameter test in RandomDataImpl#nextExponential. The method now throws
+        IllegalArgumentException for mean = 0.
+      </action>
       <action dev="brentworden" type="update" issue="MATH-311" due-to="Nipun Jawalkar">
         Changed probability calculations for Binomial, Poisson, and Hypergeometric
         distributions to use Catherine Loader's saddle point approximations.

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java?rev=831510&r1=831509&r2=831510&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/RandomDataTest.java
Sat Oct 31 02:30:18 2009
@@ -563,7 +563,12 @@
 		} catch (IllegalArgumentException ex) {
 			// ignored
 		}
-		assertEquals("0 mean", 0, randomData.nextExponential(0), 10E-8);
+        try {
+            randomData.nextExponential(0);
+            fail("zero mean -- expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // ignored
+        }
 		long cumFreq = 0;
 		double v = 0;
 		for (int i = 0; i < largeSampleSize; i++) {



Mime
View raw message