[Rd] qnbinom with small size is slow

Constantin Ahlmann-Eltze @rtjom31415 @end|ng |rom goog|em@||@com
Fri Aug 7 20:01:09 CEST 2020


Hi all,

I recently noticed that `qnbinom()` can take a long time to calculate
a result if the `size` argument is very small.
For example
   qnbinom(0.5, mu = 3, size = 1e-10)
takes ~30 seconds on my computer.

I used gdb to step through the qnbinom.c implementation and noticed
that in line 106
(https://github.com/wch/r-source/blob/f8d4d7d48051860cc695b99db9be9cf439aee743/src/nmath/qnbinom.c#L106)
`y` becomes a very large negative number. Later in the function `y` is
(as far as I can see) only used as input for `pnbinom()` which is why
I would assume that it should be a non-negative integer.

I was wondering if this behavior could be considered a bug and should
be reported on the bugzilla? I read the instructions at
https://www.r-project.org/bugs.html and wasn't quite sure, so I
decided to ask here first :)

Best,
Constantin




PS: I tested the code with R 4.0.0 on macOS and the latest unstable
version using docker (https://github.com/wch/r-debug). The session
info is
> sessionInfo()
R Under development (unstable) (2020-08-06 r78973)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/local/RD/lib/R/lib/libRblas.so
LAPACK: /usr/local/RD/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.1.0



More information about the R-devel mailing list