qpoisR {DPQ} | R Documentation |
Pure R Implementation of R's qpois() 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(qpoisR1, *)
where the hidden
qpoisR1
works for numbers (aka ‘scalar’, length one)
arguments only, the same as the C code.
Usage
qpoisR(p, lambda, 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 , lambda , lower.tail , log.p |
|
yLarge |
a positive number; in R up to 2021, was internally
hardwired to |
incF |
a positive “increment factor” (originally hardwired to
0.001), used only when |
iShrink |
a positive increment shrinking factor, used only when
|
relTol |
originally hard wired to 1e-15, defines the convergence
tolerance for the search iterations when |
pfEps.n , pfEps.L |
positive factors defining “fuzz to ensure
left continuity”, both originally hardwired to p <- p * (1 - 64 *.Machine$double.eps) Now, |
fpf |
a number larger than |
trace |
logical (or integer) specifying if (and how much) output should be produced from the algorithm. |
Details
The defaults and exact meaning of the algorithmic tuning arguments from
yLarge
to fpf
were experimentally determined are subject to change.
Value
a numeric vector like p
recycled to the common lengths of p
and lambda
.
Author(s)
Martin Maechler
See Also
Examples
x <- 10*(15:25)
Pp <- ppois(x, lambda = 100, lower.tail = FALSE) # no cancellation
qPp <- qpois(Pp, lambda = 100, lower.tail=FALSE)
table(x == qPp) # all TRUE ?
## future: if(getRversion() >= "4.2") stopifnot(x == qPp) # R-devel
qpRp <- qpoisR(Pp, lambda = 100, lower.tail=FALSE)
all.equal(x, qpRp, tol = 0)
stopifnot(all.equal(x, qpRp, tol = 1e-15))