diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 3c4df2dd3..a11ce3ae3 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -51,6 +51,9 @@ If the output is not quite correct, check for invisible trailing spaces! + + Fixed unintended integer division error in PoissonDistribution sampling method. + Fixed failing unit tests for "BOBYQAOptimizer" when executed with a Oracle/Sun JVM 1.5. diff --git a/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java b/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java index 22a1b6a41..bbafc1448 100644 --- a/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java +++ b/src/main/java/org/apache/commons/math3/distribution/PoissonDistribution.java @@ -321,7 +321,7 @@ public class PoissonDistribution extends AbstractIntegerDistribution { 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;