Skip to content

Commit

Permalink
Fixed parameter test in RandomDataImpl#nextExponential. JIRA: MATH-309.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@831510 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
psteitz committed Oct 31, 2009
1 parent 90f6eba commit 0596e31
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,11 @@ public double nextGaussian(double mu, double sigma) {
* 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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/site/xdoc/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ The <action> type attribute can be add,update,fix,remove.
</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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,12 @@ public void testNextExponential() {
} 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++) {
Expand Down

0 comments on commit 0596e31

Please sign in to comment.