This should be 1 1 2 3. This PR changes the implementation of quantile.dist_mixture() to use uniroot() instead of optimise(), which seems to fix the problem (at least, to within the default tolerance of .Machine$double.eps^0.25):
cdf(<dist_sample>) is currently defined as $P(X < x)$ rather than $P(X \le x)$. I believe it should be the latter (which would also be consistent with ecdf()). For example, on master:
cdf(dist_sample(list(2)), 2)
#> x
#> 0
This should be 1. This PR changes the implementation of cdf.dist_sample() accordingly:
cdf(dist_sample(list(2)), 2)
#> x
#> 1
Tests are included for both fixes. There is also a minor fix to format(<dist_mixture>), though it didn't seem newsworthy to me.
Two minor bugfixes for some issues I ran into when trying to improve support for visualizing discrete distributions in {ggdist}:
quantile(<dist_mixture>)
gives weird results on discrete mixtures. For example, onmaster
:This should be
1 1 2 3
. This PR changes the implementation ofquantile.dist_mixture()
to useuniroot()
instead ofoptimise()
, which seems to fix the problem (at least, to within the default tolerance of.Machine$double.eps^0.25
):cdf(<dist_sample>)
is currently defined as $P(X < x)$ rather than $P(X \le x)$. I believe it should be the latter (which would also be consistent withecdf()
). For example, onmaster
:This should be
1
. This PR changes the implementation ofcdf.dist_sample()
accordingly:Tests are included for both fixes. There is also a minor fix to
format(<dist_mixture>)
, though it didn't seem newsworthy to me.