Exp1 | R Documentation |
Density, distribution function, quantile function and random
generation for the one-parameter Exponential Distribution
distribution with scale parameter scale
.
dexp1(x, scale = 1, log = FALSE, deriv = FALSE, hessian = FALSE)
pexp1(q, scale = 1, lower.tail = TRUE, deriv = FALSE, hessian = FALSE)
qexp1(p, scale = 1, lower.tail = TRUE, deriv = FALSE, hessian = FALSE)
rexp1(n, scale = 1, array)
x, q |
Vector of quantiles. |
scale |
Scale parameter. Numeric vector with suitable length, see Details. |
log |
Logical; if |
deriv |
Logical. If |
hessian |
Logical. If |
lower.tail |
Logical; if |
p |
Vector of probabilities. |
n |
Sample size. |
array |
Logical. If |
The survival and density functions are given by
S(x) = \exp\{-x / \sigma\} \qquad
f(x) = \frac{1}{\sigma} \exp\{-x / \sigma\} \qquad (x > 0)
where \sigma
is the scale parameter. This distribution is
the Generalized Pareto Distribution for a shape \xi = 0
.
The probability functions d
, p
and q
all allow the parameter scale
to be a vector. Then the
recycling rule is used to get two vectors of the same length,
corresponding to the first argument and to the scale
parameter. This behaviour is the standard one for the
probability functions of the stats package but is
unusual in R packages devoted to Extreme Value in which the
parameters must generally have length one. Note that the
provided functions can be used e.g. to evaluate the quantile
with a given probability for a large number of values of the
parameter vector shape
. This is frequently required in
he Bayesian framework with MCMC inference.
A numeric vector with its length equal to the maximum of
the two lengths: that of the first argument and that of the
parameter scale
. When deriv
is TRUE
, the
returned value has an attribute named "gradient"
which
is a matrix with n
lines and 1
column containing
the derivative. A row contains the partial derivative of the
corresponding element w.r.t. the parameter "scale"
.
The attributes "gradient"
and "hessian"
have
dimension c(n, 1)
and c(n, 1, 1)
, even when
n
equals 1
. Use the drop
method on these
objects to drop the extra dimension if wanted i.e. to get a
gradient vector and a Hessian matrix.
The exponential distribution
Exponential
with rate
being the
inverse scale.
## Illustrate the effect of recycling rule.
pexp1(1.0, scale = 1:4, lower.tail = FALSE) - exp(-1.0 / (1:4))
pexp1(1:4, scale = 1:4, lower.tail = FALSE) - exp(-1.0)
## With gradient and Hessian.
pexp1(c(1.1, 1.7), scale = 1, deriv = TRUE, hessian = TRUE)
ti <- 1:60; names(ti) <- 2000 + ti
sigma <- 1.0 + 0.7 * ti
## simulate 40 paths
y <- rexp1(n = 40, scale = sigma)
matplot(ti, y, type = "l", col = "gray", main = "varying scale")
lines(ti, apply(y, 1, mean))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.