Gilles created MATH-1396:
----------------------------

             Summary: Overflows in "UniformIntegerDistribution"
                 Key: MATH-1396
                 URL: https://issues.apache.org/jira/browse/MATH-1396
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.6.1
            Reporter: Gilles
            Assignee: Gilles
             Fix For: 4.0


In {{o.a.c.m.distribution.UniformIntegerDistribution}}, several methods will 
compute an invalid result when the {{lower}} and {{upper}} bounds are such that
{noformat}
upper - lower
{noformat}
overflows.

Affected methods:
* {{probability}}
* {{cumulativeProbability}}
* {{getNumericalVariance}}

Method
* {{getNumericalMean}}

will return an invalid result when
{noformat}
upper + lower
{noformat}
overflows.

A possible fix is to define instances variables
{noformat}
upperPlusLower = (double) upper + (double) lower;
upperMinusLower = (double) upper - (double) lower;
{noformat}
and use them instead of the respective integer operations in the above methods.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to