Affects Version/s: 3.0, 4.0
Fix Version/s: 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.
new HypergeometricDistribution(null, 10, 0, 1).logProbability(0)
returns 0 as expected.
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.