commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arman Bilge (JIRA)" <j...@apache.org>
Subject [jira] [Created] (MATH-1384) HypergeometricDistribution logProbability() returns NaN for edge cases
Date Tue, 06 Sep 2016 02:27:21 GMT
Arman Bilge created MATH-1384:
---------------------------------

             Summary: HypergeometricDistribution logProbability() returns NaN for edge cases
                 Key: MATH-1384
                 URL: https://issues.apache.org/jira/browse/MATH-1384
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.0, 4.0
            Reporter: Arman Bilge
            Priority: Minor


For certain edge cases, HypergeometricDistribution.logProbability() will return NaN.

To compute the hypergeometric log probability, three binomial log probabilities are computed
and then combined accordingly. The implementation is essentially the same as in BinomialDistribution.logProbability()
and uses the SaddlePointExpansion. However, the Binomial implementation includes an extra
check for the edge case of 0 trials which the HyperGeometric lacks.

An example call which fails is:
new HypergeometricDistribution(null, 11, 0, 1).logProbability(0)
which returns NaN instead of 0.0.
Note that
new HypergeometricDistribution(null, 10, 0, 1).logProbability(0)
returns 0 as expected.

Possible fixes:
1. Check for the edge cases and return appropriate values. This would make the code somewhat
more complex.
2. Instead of duplicating the implementation use BinomialDistribution.logProbability(). This
is much simpler/more readable but will reduce performance as each call to BinomialDistribution.logProbability()
makes redundant checks of validity of input parameters etc.

I am happy to submit a PR at the GitHub repo implementing either 1 or 2 with the necessary
tests.



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

Mime
View raw message