Density, cumulative distribution function, quantile function and random generation for the Perks distribution.

dperks(x, scale = 1, shape, log = FALSE)
pperks(q, scale = 1, shape, lower.tail = TRUE, log.p = FALSE)
qperks(p, scale = 1, shape, lower.tail = TRUE, log.p = FALSE)
rperks(n, scale = 1, shape)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations. Same as in runif.

log

Logical. If log = TRUE then the logarithm of the density is returned.

lower.tail, log.p

Same meaning as in pnorm or qnorm.

shape, scale

positive shape and scale parameters.

Value

dperks gives the density, pperks gives the cumulative distribution function, qperks gives the quantile function, and rperks generates random deviates.

Author

T. W. Yee and Kai Huang

Details

See perks for details.

See also

Examples

probs <- seq(0.01, 0.99, by = 0.01)
Shape <- exp(-1.0); Scale <- exp(1);
max(abs(pperks(qperks(p = probs, Shape, Scale),
                  Shape, Scale) - probs))  # Should be 0
#> [1] 5.689893e-16

if (FALSE)  x <- seq(-0.1, 07, by = 0.01);
plot(x, dperks(x, Shape, Scale), type = "l", col = "blue", las = 1,
     main = "Blue is density, orange is cumulative distribution function",
     sub = "Purple lines are the 10,20,...,90 percentiles",
     ylab = "", ylim = 0:1)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'x' not found
abline(h = 0, col = "blue", lty = 2)
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet
lines(x, pperks(x, Shape, Scale), col = "orange")
#> Error: object 'x' not found
probs <- seq(0.1, 0.9, by = 0.1)
Q <- qperks(probs, Shape, Scale)
lines(Q, dperks(Q, Shape, Scale), col = "purple", lty = 3, type = "h")
#> Error in plot.xy(xy.coords(x, y), type = type, ...): plot.new has not been called yet
pperks(Q, Shape, Scale) - probs  # Should be all zero
#> [1] -5.551115e-16  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00
#> [6] -2.220446e-16 -2.220446e-16  0.000000e+00  0.000000e+00
abline(h = probs, col = "purple", lty = 3)  # \dontrun{}
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet