[ https://issues.apache.org/jira/browse/MATH1056?page=com.atlassian.jira.plugin.system.issuetabpanels:alltabpanel
]
Sean Owen updated MATH1056:

Description:
Here's a tiny bug I noticed via static inspection, since it flagged the integer division.
PoissonDistribution.java:325 says:
{code:java}
final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / 8 * lambda);
{code}
The "1 / 8 * lambda" is evidently incorrect, since this will always evaluate to 0. I rechecked
the original algorithm (http://luc.devroye.org/devroyepoisson.pdf) and it should instead
be:
{code:java}
final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / (8 * lambda));
{code}
(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.
was:
Here's a tiny bug I noticed via static inspection, since it flagged the integer division.
PoissonDistribution.java:325 says:
{code:java}
final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / 8 * lambda);
{code}
The "1 / 8 * lambda)" is evidently incorrect, since this will always evaluate to 0. I rechecked
the original algorithm (http://luc.devroye.org/devroyepoisson.pdf) and it should instead
be:
{code:java}
final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / (8 * lambda));
{code}
(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.
> Small error in PoissonDistribution.nextPoisson() algorithm
> 
>
> Key: MATH1056
> URL: https://issues.apache.org/jira/browse/MATH1056
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.2
> Reporter: Sean Owen
> Priority: Minor
> Attachments: MATH1056.patch
>
>
> Here's a tiny bug I noticed via static inspection, since it flagged the integer division.
PoissonDistribution.java:325 says:
> {code:java}
> final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / 8 * lambda);
> {code}
> The "1 / 8 * lambda" is evidently incorrect, since this will always evaluate to 0. I
rechecked the original algorithm (http://luc.devroye.org/devroyepoisson.pdf) and it should
instead be:
> {code:java}
> final double a1 = FastMath.sqrt(FastMath.PI * twolpd) * FastMath.exp(1 / (8 * lambda));
> {code}
> (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.

This message was sent by Atlassian JIRA
(v6.1#6144)
