[ 
https://issues.apache.org/jira/browse/MATH-1384?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15466591#comment-15466591
 ] 

Arman Bilge commented on MATH-1384:
-----------------------------------

True; sorry for the duplicate. Where is the commit with the fix?

> 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)

Reply via email to