You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2013/11/09 00:27:50 UTC
svn commit: r1540217 - in /commons/proper/math/trunk/src: changes/changes.xml
main/java/org/apache/commons/math3/distribution/PoissonDistribution.java
Author: psteitz
Date: Fri Nov 8 23:27:49 2013
New Revision: 1540217
URL: http://svn.apache.org/r1540217
Log:
Fixed unintended integer division error in PoissonDistribution sampling method.
JIRA: MATH-1056
Reported and patched by Sean Owen.
Modified:
commons/proper/math/trunk/src/changes/changes.xml
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java
Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1540217&r1=1540216&r2=1540217&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Fri Nov 8 23:27:49 2013
@@ -51,6 +51,9 @@ If the output is not quite correct, chec
</properties>
<body>
<release version="3.3" date="TBD" description="TBD">
+ <action dev="psteitz" type="fix" issue="MATH-1056" due-to="Sean Owen">
+ Fixed unintended integer division error in PoissonDistribution sampling method.
+ </action>
<action dev="tn" type="fix" issue="MATH-1057">
Fixed failing unit tests for "BOBYQAOptimizer" when executed with a Oracle/Sun JVM 1.5.
</action>
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java?rev=1540217&r1=1540216&r2=1540217&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java Fri Nov 8 23:27:49 2013
@@ -321,7 +321,7 @@ public class PoissonDistribution extends
final double delta = FastMath.sqrt(lambda * FastMath.log(32 * lambda / FastMath.PI + 1));
final double halfDelta = delta / 2;
final double twolpd = 2 * lambda + delta;
- final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / 8 * lambda);
+ final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / (8 * lambda));
final double a2 = (twolpd / delta) * FastMath.exp(-delta * (1 + delta) / twolpd);
final double aSum = a1 + a2 + 1;
final double p1 = a1 / aSum;