Description Usage Arguments Details Value Warning See Also Examples
Density, distribution function, quantile function and random generation for the Laplace distribution with location parameter loc
and scale parameter scale
.
1 2 3 4 |
x,q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of samples to generate. |
loc |
vector of location parameters. |
scale |
vector of scale parameters. These must be positive. |
lower.tail |
logical; if TRUE (default), probabilities are Pr(X≤ x), otherwise Pr(X>x). |
log,log.p |
logical; if TRUE, probabilities p are given as log(p). |
If loc
or scale
are not specified, they assume the default values of 0 and 1 respectively.
The Laplace distribution has density
f(x) = \exp(- |x-μ|/σ)/(2σ)
where μ is the location parameter and σ is the scale parameter.
dlapl
gives the density, plapl
gives the distribution function, qlapl
gives the quantile function, and rlapl
generates random deviates.
The length of the result is determined by n
in rlapl
, and is the maximum of the lengths of the numerical arguments for the other functions. Standard R
vector operations are to be assumed.
If sd
=0, the limit as sd
decreases to 0 is returned, i.e., a point mass at loc
. The case sd
<0 is an error and nothing is returned.
Some checks are done previous to standard evaluation, but vector computations have not yet been tested thoroughly! Typically vectors not having lengths multiple of each other return an error.
dexp for the exponential distribution which is the positive part of the Laplace distribution.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## evaluate the density function on a grid of values
x <- seq(from=-5, to=5, by=0.1)
fx <- dlapl(x, loc=1, scale=.5)
## generate random samples of a mixture of Laplace distributions
rnd <- rlapl(1000, loc=c(-5,-3,2), scale=0.5)
## an alternative:
rnd <- runif(1000)
rnd <- qlapl(rnd, loc=c(-5,-3,2), scale=0.5)
## integrate the Laplace density on [a,b]
a <- -1
b <- 7
integral <- plapl(b)-plapl(a)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.