Re: [Numpy-discussion] Using logfactorial instead of loggamma in random_poisson sampler

2021-03-08 Thread zoj613
What do you think is the explanation for that? I had assumed that using a lookup table would be faster considering that the loggam implementation has loops and makes calls to elementary functions in it. -- Sent from: http://numpy-discussion.10968.n7.nabble.com/

Re: [Numpy-discussion] Using logfactorial instead of loggamma in random_poisson sampler

2021-03-08 Thread Kevin Sheppard
I did a quick test and using random_loggam was about 6% faster than using logfactorial (on Windows). Kevin On Sun, Mar 7, 2021 at 2:40 AM Robert Kern wrote: > On Sat, Mar 6, 2021 at 1:45 PM Warren Weckesser < > warren.weckes...@gmail.com> wrote: > >> At the time, making that change was not a

Re: [Numpy-discussion] Using logfactorial instead of loggamma in random_poisson sampler

2021-03-06 Thread Robert Kern
On Sat, Mar 6, 2021 at 1:45 PM Warren Weckesser wrote: > At the time, making that change was not a high priority, so I didn't > pursue it. It does make sense to use the logfactorial function there, > and I'd be happy to see it updated, but be aware that making the > change is more work than

Re: [Numpy-discussion] Using logfactorial instead of loggamma in random_poisson sampler

2021-03-06 Thread zoj613
Ah, I had a suspicion that it was to preserve the random stream but wasn't too sure. Thanks for the clarification. -- Sent from: http://numpy-discussion.10968.n7.nabble.com/ ___ NumPy-Discussion mailing list NumPy-Discussion@python.org

Re: [Numpy-discussion] Using logfactorial instead of loggamma in random_poisson sampler

2021-03-06 Thread Warren Weckesser
On 3/6/21, zoj613 wrote: > Hi All, > > I noticed that the transformed rejection method for generating Poisson > random variables used in numpy makes use of the `random_loggam` function > which directly calculates the log-gamma function. It appears that a > log-factorial lookup table was added a

[Numpy-discussion] Using logfactorial instead of loggamma in random_poisson sampler

2021-03-06 Thread zoj613
Hi All, I noticed that the transformed rejection method for generating Poisson random variables used in numpy makes use of the `random_loggam` function which directly calculates the log-gamma function. It appears that a log-factorial lookup table was added a few years back which could be used in