dnbinomR | R Documentation |
Compute pure R implementations of R's C Mathlib (Rmath)
dnbinom()
binomial probabilities, allowing to see the
effect of the cutoff eps
.
dnbinomR (x, size, prob, log = FALSE, eps = 1e-10)
dnbinom.mu(x, size, mu, log = FALSE, eps = 1e-10)
x , size , prob , mu , log |
see R's |
eps |
non-negative number specifying the cutoff for “small
|
numeric vector of the same length as x
which may have to be
thought of recycled along size
and prob
or mu
.
R Core and Martin Maechler
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.
dbinom_raw
;
Note that our CRAN package Rmpfr provides
dnbinom
,
dbinom
and more, where mpfr-accurate functions are
used instead of R's (and our pure R version of) bd0()
and
stirlerr()
.
stopifnot( dnbinomR(0, 1, 1) == 1 )
size <- 1000 ; x <- 0:size
dnb <- dnbinomR(x, size, prob = 5/8, log = FALSE, eps = 1e-10)
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 = 1e-10)
all.equal(dnbm, dnbinom(x, size, mu = 123)) # Mean relative diff: 0.00069...
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.