dnbinomR {DPQ}  R Documentation 
Pure R Versions of R's C (Mathlib) dnbinom() Negative Binomial Probabilities
Description
Compute pure R implementations of R's C Mathlib (Rmath)
dnbinom()
binomial probabilities, allowing to see the
effect of the cutoff eps
.
Usage
dnbinomR (x, size, prob, log = FALSE, eps = 1e10)
dnbinom.mu(x, size, mu, log = FALSE, eps = 1e10)
Arguments
x , size , prob , mu , log 
see R's 
eps 
nonnegative number specifying the cutoff for “small

Value
numeric vector of the same length as x
which may have to be
thought of recycled along size
and prob
or mu
.
Author(s)
R Core and Martin Maechler
References
Abramowitz, M. and Stegun, I. A. (1972) Handbook of Mathematical Functions. New York: Dover. https://en.wikipedia.org/wiki/Abramowitz_and_Stegun provides links to the full text which is in public domain.
See Also
dbinom_raw
;
Note that our CRAN package Rmpfr provides
dnbinom
,
dbinom
and more, where mpfraccurate functions are
used instead of R's (and our pure R version of) bd0()
and
stirlerr()
.
Examples
stopifnot( dnbinomR(0, 1, 1) == 1 )
size < 1000 ; x < 0:size
dnb < dnbinomR(x, size, prob = 5/8, log = FALSE, eps = 1e10)
plot(x, dnb, type="b")
all.equal(dnb, dnbinom(x, size, prob = 5/8)) ## mean rel. diff: 0.00017...
dnbm < dnbinom.mu(x, size, mu = 123, eps = 1e10)
all.equal(dnbm, dnbinom(x, size, mu = 123)) # Mean relative diff: 0.00069...