pqnormAsymp | R Documentation |
These functions provide the first terms of asymptotic series approximations to
pnorm()
's (extreme) tail, from Abramawitz and Stegun's
26.2.13 (p.932),
or qnorm()
where the approximations have been derived via
iterative plugin using Abramowitz and Stegun's formula.
pnormAsymp(x, k, lower.tail = FALSE, log.p = FALSE)
qnormAsymp(p, lp = .DT_Clog(p, lower.tail = lower.tail, log.p = log.p),
order, M_2PI =,
lower.tail = TRUE, log.p = missing(p))
x |
positive (at least non-negative) numeric vector. |
k |
integer |
p |
numeric vector of probabilities, possibly transformed, depending
on |
lp |
numeric (vector) of |
order |
an integer in |
M_2PI |
the number |
lower.tail |
logical; if true, probabilities are |
log.p |
logical; if |
see both help pages pnormAsymp
and
qnormAsymp
from our package DPQ.
vector/array/mpfr like first argument x
or p
or lp
, respectively.
Martin Maechler
pnorm
. The same functions “numeric-only” are in my
DPQ package with more extensive documentation.
require("Rmpfr") # (in strong dependencies of this pkg {DPQmpfr})
x <- seq(1/64, 10, by=1/64)
xm <- mpfr( x, 96)
"TODO"
## More extreme tails: ----------------------------------------------
##
## 1. pnormAsymp() ---------------------
lx <- c((2:10)*2, 25, (3:9)*10, (1:9)*100, (1:8)*1000, (2:7)*5000)
lxm <- mpfr(lx, 256)
Px <- pnorm(lxm, lower.tail = FALSE, log.p=TRUE)
PxA <- sapplyMpfr(setNames(0:5, paste("k =",0:5)),
pnormAsymp, x=lxm, lower.tail = FALSE, log.p=TRUE)
if(interactive())
roundMpfr(PxA, 40)
# rel.errors :
relE <- asNumeric(1 - PxA/Px)
options(width = 99) -> oop # (nicely printing the matrices)
cbind(lx, relE)
matplot(lx, abs(relE), type="b", cex = 1/2, log="xy", pch=as.character(0:5),
axes=FALSE,
main = "|relE( <pnormAsymp(lx, k=*, lower.tail=FALSE, log.p=TRUE) )|")
sfsmisc::eaxis(1, sub10=2); sfsmisc::eaxis(2)
legend("bottom", paste("k =", 0:5), col=1:6, lty=1:5,
pch = as.character(0:5), pt.cex=1/2, bty="n")
## NB: rel.Errors go down to 7e-59 ==> need precision of -log2(7e-59) ~ 193.2 bits
## 2. qnormAsymp() ---------------------
QPx <- sapplyMpfr(setNames(0:5, paste("k =",0:5)),
function(k) qnormAsymp(Px, order=k, lower.tail = FALSE, log.p=TRUE))
(relE.q <- asNumeric(QPx/lx - 1))
# note how consistent the signs are (!) <==> have upper/lower bounds
matplot(-asNumeric(Px), abs(relE.q), type="b", cex = 1/2, log="xy", pch=as.character(0:5),
xlab = quote(-Px), axes=FALSE,
main = "|relE( <qnormAsymp(Px, k=*, lower.tail=FALSE, log.p=TRUE) )|")
sfsmisc::eaxis(1, sub10=2); sfsmisc::eaxis(2)
legend("bottom", paste("k =", 0:5), col=1:6, lty=1:5,
pch = as.character(0:5), pt.cex=1/2, bty="n")
options(oop) # {revert to previous state}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.