Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.2
-
None
-
None
Description
Here's a tiny bug I noticed via static inspection, since it flagged the integer division. PoissonDistribution.java:325 says:
final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / 8 * lambda);
The "1 / 8 * lambda" is evidently incorrect, since this will always evaluate to 0. I rechecked the original algorithm (http://luc.devroye.org/devroye-poisson.pdf) and it should instead be:
final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / (8 * lambda));
(lambda is a double so there is no int division issue.) This matches a later expression.
I'm not sure how to evaluate the effect of the bug. Better to be correct of course; it may never have made much practical difference.