On Fri, 27 Sep 2019, Alecos Papadopoulos wrote:
Are we sure that the invcdf function works correctly for the case of
discrete
distributions?
The inverse CDF method of generating a random variable using a Uniform[0,1]
is valid also for discrete rv's (by using the generalized inverse), so I
tried
<hansl>
series U = randgen(U,0,1) # generate Uniform(0,1)
series Xd = invcdf(P, 2, U) # generate Poisson with mean 2
</hansl>
but the Xd series did not have integer values, so it cannot be a
Poisson rv.
Hmm, it seems there's something odd about the cephes function we're
using to give the answer here, namely pdtri(). For the most part the
cephes suite, written by Stephen Moshier, is fast and accurate, but
I agree that something looks to be amiss here. I'll try to find out
what.
(In case anyone is able to help: cephes' pdtri() takes two
arguments, an integer k and a double 0 < y < 1 (probability). And
the doc says "Finds the Poisson variable x such that the integral
from 0 to x of the Poisson density is equal to the given probability
y." So what's "k"? If it's the mean (= variance) it shouldn't
have
to be an integer, should it?)
Allin Cottrell