Last chance! 50% off unlimited learning
Sale ends in
Compute quantiles (inverse distribution values) for the beta distribution, using diverse approximations.
qbetaAppr.1(a, p, q, y = qnormUappr(a))
qbetaAppr.2(a, p, q, lower.tail=TRUE, log.p=FALSE, logbeta = lbeta(p,q))
qbetaAppr.3(a, p, q, lower.tail=TRUE, log.p=FALSE, logbeta = lbeta(p,q))
qbetaAppr.4(a, p, q, y = qnormUappr(a),
verbose = getOption("verbose"))qbetaAppr (a, p, q, y = qnormUappr(a), logbeta= lbeta(p,q),
verbose = getOption("verbose") && length(a) == 1)
qbeta.R (alpha, p, q,
lower.tail = TRUE, log.p = FALSE,
logbeta = lbeta(p,q),
low.bnd = 3e-308, up.bnd = 1-2.22e-16,
method = c("AS109", "Newton-log"),
tol.outer = 1e-15,
f.acu = function(a,p,q) max(1e-300, 10^(-13- 2.5/pp^2 - .5/a^2)),
fpu = .Machine$ double.xmin,
qnormU.fun = function(u, lu) qnormUappr(p=u, lp=lu)
, R.pre.2014 = FALSE
, verbose = getOption("verbose")
, non.finite.report = verbose
)
vector of probabilities (otherwise, e.g., in
qbeta()
, called p
).
the two shape parameters of the beta distribution; otherwise, e.g., in
qbeta()
, called shape1
and shape2
.
an approximation to qnorm(x)
.
logical, see, e.g., qchisq()
; must
have length 1.
must be lbeta(p,q)
; mainly an option to pass
a value already computed.
logical or integer indicating if and how much “monitoring” information should be produced by the algorithm.
lower and upper bounds for ...TODO...
a string specifying the approximation method to be used.
the “outer loop” convergence tolerance; the
default 1e-15
has been hardwired in R's qbeta()
.
a function
with arguments (a,p,q)
...TODO...
a very small positive number.
a function
with arguments (u,lu)
to compute “the same” as qnormUappr()
, the upper
standard normal quantile.
a logical
... TODO ...
logical
indicating if during the
“outer loop” refining iterations, if y
becomes non finite
and the iterations have to stop, it should be reported (before the
current best value is returned).
...
# NOT RUN {
qbeta.R(0.6, 2, 3) # 0.4445
qbeta.R(0.6, 2, 3) - qbeta(0.6, 2,3) # almost 0
qbetaRV <- Vectorize(qbeta.R, "alpha") # now can use
curve(qbetaRV(x, 1.5, 2.5))
curve(qbeta (x, 1.5, 2.5), add=TRUE, lwd = 3, col = adjustcolor("red", 1/2))
## an example of disagreement (and doubt, as borderline, close to underflow):
qbeta.R(0.5078, .01, 5) # -> 2.77558e-15 # but
qbeta (0.5078, .01, 5) # -> 1.776357e-15 now gives 4.651188e-31 !!!
qbeta (0.5078, .01, 5, ncp=0) # also gives 4.651188e-31
# }
Run the code above in your browser using DataLab