Distributions.jl icon indicating copy to clipboard operation
Distributions.jl copied to clipboard

Fix inconsistent return types of `quantile` etc.

Open devmotion opened this issue 2 years ago • 1 comments

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.

devmotion avatar Nov 23 '23 16:11 devmotion

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

Files with missing lines Patch % Lines
src/univariate/discrete/bernoullilogit.jl 0.00% 4 Missing :warning:
src/univariate/discrete/negativebinomial.jl 87.50% 2 Missing :warning:
src/univariate/discrete/binomial.jl 97.36% 1 Missing :warning:
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.

codecov-commenter avatar Sep 26 '24 07:09 codecov-commenter