| dlaplace {greybox} | R Documentation |
Laplace Distribution
Description
Density, cumulative distribution, quantile functions and random number generation for the Laplace distribution with the location parameter mu and the scale parameter (which is equal to Mean Absolute Error, aka Mean Absolute Deviation).
Usage
dlaplace(q, mu = 0, scale = 1, log = FALSE)
plaplace(q, mu = 0, scale = 1)
qlaplace(p, mu = 0, scale = 1)
rlaplace(n = 1, mu = 0, scale = 1)
Arguments
q |
vector of quantiles. |
mu |
vector of location parameters (means). |
scale |
vector of mean absolute errors. |
log |
if |
p |
vector of probabilities. |
n |
number of observations. Should be a single number. |
Details
When mu=0 and scale=1, the Laplace distribution becomes standardized. The distribution has the following density function:
f(x) = 1/(2 scale) exp(-abs(x-mu) / scale)
Both plaplace and qlaplace are returned for the lower
tail of the distribution.
Value
Depending on the function, various things are returned (usually either vector or scalar):
-
dlaplacereturns the density function value for the provided parameters. -
plaplacereturns the value of the cumulative function for the provided parameters. -
qlaplacereturns quantiles of the distribution. Depending on what was provided inp,muandscale, this can be either a vector or a matrix, or an array. -
rlaplacereturns a vector of random variables generated from the Laplace distribution. Depending on what was provided inmuandscale, this can be either a vector or a matrix or an array.
Author(s)
Ivan Svetunkov, ivan@svetunkov.ru
References
Wikipedia page on Laplace distribution: https://en.wikipedia.org/wiki/Laplace_distribution.
See Also
Examples
x <- dlaplace(c(-100:100)/10, 0, 1)
plot(x, type="l")
x <- plaplace(c(-100:100)/10, 0, 1)
plot(x, type="l")
qlaplace(c(0.025,0.975), 0, c(1,2))
x <- rlaplace(1000, 0, 1)
hist(x)