Fix inconsistent return types of quantile
etc.
#1805
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 toInt
to match the type of the variates. However, the behaviour of some distributions such asGeometric
orBernoulli
is inconsistent: The return type ofquantile
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
andStatsFuns.RFunctions.hyperinvlogccdf(2, 2, 2, -Inf) = NaN
which so far we have hidden by skipping them in the tests).Fixes #1798.