Distributions.jl
Distributions.jl copied to clipboard
Fix inconsistent return types of `quantile` etc.
Currently, the return type of quantile etc. is inconsistent, in particular for discrete distributions. For many distributions (and in particular those for which we fall back to StatsFuns/Rmath) the return type is explicitly to converted to Int to match the type of the variates. However, the behaviour of some distributions such as Geometric or Bernoulli is inconsistent: The return type of quantile does not match the type of the variates.
This PR fixes the inconsistency. Moreover, I added tests to avoid regressions and made an existing test a bit stricter. These tests revealed a few additional problems (e.g. caused by the Rmath behaviour that StatsFuns.RFunctions.binominvcdf(10, 1.0, 0.0) = 0 and StatsFuns.RFunctions.hyperinvlogccdf(2, 2, 2, -Inf) = NaN which so far we have hidden by skipping them in the tests).
Fixes #1798.
Codecov Report
Attention: Patch coverage is 94.85294% with 7 lines in your changes missing coverage. Please review.
Project coverage is 86.29%. Comparing base (
a1010e4) to head (8345f1c).
Additional details and impacted files
@@ Coverage Diff @@
## master #1805 +/- ##
==========================================
+ Coverage 86.08% 86.29% +0.21%
==========================================
Files 144 144
Lines 8696 8788 +92
==========================================
+ Hits 7486 7584 +98
+ Misses 1210 1204 -6
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.