You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Arman Bilge (JIRA)" <ji...@apache.org> on 2016/09/06 06:49:21 UTC

[jira] [Resolved] (MATH-1384) HypergeometricDistribution logProbability() returns NaN for edge cases

     [ https://issues.apache.org/jira/browse/MATH-1384?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Arman Bilge resolved MATH-1384.
-------------------------------
       Resolution: Duplicate
    Fix Version/s: 4.0

> 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
>             Fix For: 4.0
>
>
> 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)