qnbinomR {DPQ} | R Documentation |
Pure R Implementation of R's qnbinom() with Tuning Parameters
Description
A pure R implementation, including many tuning parameter arguments, of R's own Rmathlib C code algorithm, but with more flexibility.
It is using Vectorize(qnbinomR1, *)
where the hidden
qnbinomR1
works for numbers (aka ‘scalar’, length one)
arguments only, the same as the C code.
Usage
qnbinomR(p, size, prob, mu, lower.tail = TRUE, log.p = FALSE,
yLarge = 4096, # was hard wired to 1e5
incF = 1/64, # was hard wired to .001
iShrink = 8, # was hard wired to 100
relTol = 1e-15,# was hard wired to 1e-15
pfEps.n = 8, # was hard wired to 64: "fuzz to ensure left continuity"
pfEps.L = 2, # was hard wired to 64: " " ..
fpf = 4, # *MUST* be >= 1 (did not exist previously)
trace = 0)
Arguments
p , size , prob , mu , lower.tail , log.p |
|
yLarge , incF , iShrink , relTol , pfEps.n , pfEps.L , fpf |
numeric
arguments tweaking the “root finding” search after the initial
Cornish-Fisher approximation, see |
trace |
logical (or integer) specifying if (and how much) output should be produced from the algorithm. |
Value
a numeric vector like p
recycled to the common lengths of
p
, size
, and either prob
or mu
.
Author(s)
Martin Maechler
See Also
Examples
set.seed(12)
x10 <- rnbinom(500, mu = 4, size = 10) ; p10 <- pnbinom(x10, mu=4, size=10)
x1c <- rnbinom(500, prob = 31/32, size = 100); p1c <- pnbinom(x1c, prob=31/32, size=100)
stopifnot(exprs = {
x10 == qnbinom (p10, mu=4, size=10)
x10 == qnbinomR(p10, mu=4, size=10)
x1c == qnbinom (p1c, prob=31/32, size=100)
x1c == qnbinomR(p1c, prob=31/32, size=100)
})