qbinomR {DPQ} | R Documentation |
A pure R implementation, including many tuning parameter arguments, of R's own Mathlib C code algorithm, but with more flexibility.
It is using Vectorize(qbinomR1, *)
where the hidden
qbinomR1
works for numbers (aka ‘scalar’, length one)
arguments only, the same as the C code.
qbinomR(p, size, prob, 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)
p, size, prob, lower.tail, log.p |
|
yLarge |
|
incF |
|
iShrink |
|
relTol |
|
pfEps.n |
|
pfEps.L |
|
fpf |
|
trace |
logical (or integer) specifying if (and how much) output should be produced from the algorithm. |
a numeric vector like p
recycled to the common lengths of
p
, size
, and prob
.
Martin Maechler
set.seed(12) pr <- (0:16)/16 # supposedly recycled x10 <- rbinom(500, prob=pr, size = 10); p10 <- pbinom(x10, prob=pr, size= 10) x1c <- rbinom(500, prob=pr, size = 100); p1c <- pbinom(x1c, prob=pr, size=100) ## stopifnot(exprs = { table( x10 == (qp10 <- qbinom (p10, prob=pr, size= 10) )) table( qp10 == (qp10R <- qbinomR(p10, prob=pr, size= 10) )); summary(warnings()) # 30 x NaN table( x1c == (qp1c <- qbinom (p1c, prob=pr, size=100) )) table( qp1c == (qp1cR <- qbinomR(p1c, prob=pr, size=100) )); summary(warnings()) # 30 x NaN ## })