Density, distribution, and random generation functions for a selected order statistic (the j-th largest or smallest value) from a sample of a given size drawn from any specified distribution, derived analytically using the beta distribution representation of order statistics.
Usage
dorder(x, dFun, pFun, ..., distn, mlen = 1, j = 1, largest = TRUE, log = FALSE)
porder(
q,
pFun,
...,
distn,
mlen = 1,
j = 1,
largest = TRUE,
lower.tail = TRUE,
log.p = FALSE
)
rorder(n, qFun, ..., distn, mlen = 1, j = 1, largest = TRUE)Arguments
- x, q
vector of quantiles.
- dFun, pFun, qFun
density, distribution and quantile function of the specified distribution. The density function must have a
logargument (a simple wrapper can always be constructed to achieve this).- ...
parameters of the specified distribution.
- distn
a character string, optionally specified as an alternative to
dFun,pFunandqFunsuch that the density, distribution and quantile functions are formed upon the addition of the prefixesd,pandqrespectively.- mlen
the number of independent variables.
- j
the order statistic, taken as the
jth largest (default) or smallest ofmlen, according to the value oflargest.- largest
logical; if
TRUE(default) use thejth largest order statistic, otherwise use thejth smallest.- log, log.p
logical; if
TRUE, probabilitiespare given aslog(p)and the density is returned on the log scale.- lower.tail
logical; if
TRUE(default) probabilities areP[X <= x], otherwise P[X > x].- n
number of observations.
Value
dorder() gives the density function and porder()
gives the distribution function of a selected order statistic from a
sample of size mlen, from a specified distribution.
rorder() generates random deviates. There is no quantile function
for order statistics (qorder() does not exist).
Note
Based on code by Alec Stephenson previously published in the evd package, adapted to conform to package standards.
Examples
dorder(2:4, dnorm, pnorm, mean = 0.5, sd = 1.2, mlen = 5, j = 2)
#> [1] 0.2300687782 0.0133524232 0.0001663078
dorder(2:4, distn = "norm", mean = 0.5, sd = 1.2, mlen = 5, j = 2)
#> [1] 0.2300687782 0.0133524232 0.0001663078
dorder(2:4, distn = "exp", mlen = 2, j = 2)
#> [1] 0.0366312778 0.0049575044 0.0006709253
porder(2:4, distn = "exp", rate = 1.2, mlen = 2, j = 2)
#> [1] 0.9917703 0.9992534 0.9999323
rorder(5, qgamma, shape = 1, mlen = 10, j = 2)
#> [1] 1.0699673 0.9894456 1.9396696 1.7528036 2.2440109
