| pnorMix | R Documentation | 
Compute cumulative probabilities or quantiles (the inverse) for a
normal mixture specified as norMix object.
pnorMix(q, obj, lower.tail = TRUE, log.p = FALSE)
qnorMix(p, obj, lower.tail = TRUE, log.p = FALSE,
        tol = .Machine$double.eps^0.25, maxiter = 1000, traceRootsearch = 0,
        method = c("interpQspline", "interpspline", "eachRoot", "root2"),
        l.interp = pmax(1, pmin(20, 1000 / m)), n.mu.interp = 100)
obj | 
 an object of class   | 
p | 
 numeric vector of probabilities.  Note that for all
  | 
q | 
 numeric vector of quantiles  | 
.
lower.tail | 
 logical; if TRUE (default), probabilities are
  | 
log.p | 
 logical; if TRUE, probabilities p are given as log(p).  | 
tol, maxiter | 
 tolerance and maximal number of iterations for the
root search algorithm, see   | 
traceRootsearch | 
 logical or integer in   | 
method | 
 a string specifying which algorithm is used for the
“root search”.  Originally, the only method was a
variation of   | 
l.interp | 
 positive integer for   | 
n.mu.interp | 
 positive integer for   | 
Whereas the distribution function pnorMix is the trivial sum of
weighted normal probabilities (pnorm), its inverse,
qnorMix is computed numerically: For each p we search for
q such that pnorMix(obj, q) == p, i.e., f(q) = 0
for f(q) := pnorMix(obj, q) - p.  This is a root finding
problem which can be solved by uniroot(f, lower,upper,*).
If length(p) <= 2 or method = "eachRoot", this happens
one for one for the sorted p's.  Otherwise, we start by doing
this for the outermost non-trivial (0 < p < 1) values of p.
For method = "interQpspline" or "interpspline", we now compute
p. <- pnorMix(q., obj) for values q. which are a grid
of length l.interp in each interval [q_j,q_{j+1}], where
q_j are the “X-extremes” plus (a sub sequence of length
n.mu.interp of) the ordered mu[j]'s.
Then, we use montone inverse interpolation
(splinefun(q., p., method="monoH.FC")) plus
a few (maximally maxiter, typically one!) Newton steps.
The default, "interQpspline", additionally logit-transforms the
p. values to make the interpolation more linear.
This method is faster, particularly for large length(p).
a numeric vector of the same length as p or q, respectively.
Very first version (for length-1 p,q) by
Erik Jørgensen Erik.Jorgensen@agrsci.dk.
dnorMix for the density function.
MW.nm3 # the "strange skew" one
plot(MW.nm3)
## now the cumlative :
x <- seq(-4,4, length.out = 1001)
plot(x, pnorMix(x, MW.nm3), type="l", col=2)
## and some of its inverse :
pp <- seq(.1, .9, by=.1)
plot(qnorMix(pp, MW.nm3), pp)
## The "true" median of a normal mixture:
median.norMix <- function(x) qnorMix(1/2, x)
median.norMix(MW.nm3) ## -2.32
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.