qnormAppr {DPQ} | R Documentation |
Relatively simple approximations to the standard normal (aka “Gaussian”) quantiles, i.e., the inverse of the normal cumulative probability function.
qnormUappr()
is a simple approximation to (the upper tail)
standard normal quantiles, qnorm()
.
qnormAppr(p) qnormUappr(p, lp = .DT_Clog(p, lower.tail=lower.tail, log.p=log.p), lower.tail = FALSE, log.p = FALSE)
p |
numeric vector of probabilities, possibly transformed, depending
on |
lp |
|
lower.tail |
logical; if TRUE (not the default here!), probabilities are P[X ≤ x], otherwise (by default) upper tail probabilities, P[X > x]. |
log.p |
logical; if TRUE, probabilities p are given as
\log(p) in argument |
qnormAppr(p)
uses the simple 4 coefficient rational approximation
to qnorm(p)
,
to be used only for p > 1/2 in qbeta()
computations, e.g.,
qbeta.R
.
The relative error of this approximation is quite asymmetric: It
is mainly < 0.
qnormUappr(p)
uses the same rational approximation directly for the
Upper tail where it is relatively good, and for the lower tail via
“swapping the tails”, so it is good there as well.
numeric vector of (approximate) normal quantiles corresponding to
probabilities p
Martin Maechler
pp <- c(.001, .005, .01, .05, (1:9)/10, .95, .99, .995, .999) z_p <- qnorm(pp) (R <- cbind(pp, z_p, qA = qnormAppr(pp), qUA = qnormUappr(pp, lower.tail=TRUE))) ## Errors, absolute and relative: cbind(pp, (relE <- cbind( errA = z_p - R[,"qA" ], errUA = z_p - R[,"qUA"], rE.A = 1 - R[,"qA" ]/z_p, rE.UA = 1 - R[,"qUA"]/z_p))) lp <- -c(1000, 500, 200, 100, 50, 20:10, seq(9.75, 0, by = -1/8)) qnormUappr(lp=lp) # 'p' need not be specified if 'lp' is curve(qnorm(x, lower.tail=FALSE), n=1001) curve(qnormUappr(x), add=TRUE, n=1001, col = adjustcolor("red", 1/2)) curve(qnorm(x, lower.tail=FALSE) - qnormUappr(x), n=1001)