Learn R Programming

L1pack (version 0.41-24)

Laplace: The Laplace distribution

Description

Density, distribution function, quantile function and random generation for the Laplace distribution with location parameter location and scale parameter scale.

Usage

dlaplace(x, location = 0, scale = 1, log = FALSE)
plaplace(q, location = 0, scale = 1, lower.tail = TRUE, log.p = FALSE)
qlaplace(p, location = 0, scale = 1, lower.tail = TRUE, log.p = FALSE)
rlaplace(n, location = 0, scale = 1)

Value

dlaplace, plaplace, and qlaplace are respectively the density, distribution function and quantile function of the Laplace distribution. rlaplace

generates random deviates from the Laplace.

The length of the result is determined by n for rlaplace, and is the maximum of the lengths of the numerical parameters for the other functions.

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

location

location parameter \(\mu\), which is the mean.

scale

scale parameter \(\phi\). Scale must be positive.

log, log.p

logical; if TRUE, probabilities \(p\) are given as \(\log(p)\).

lower.tail

logical; if TRUE (default), probabilities are \(P[X \le x]\), otherwise, \(P[X > x]\).

Author

Felipe Osorio and Tymoteusz Wolodzko

Details

If location or scale are not specified, they assume the default values of 0 and 1 respectively.

The Laplace distribution with location \(\mu\) and scale \(\phi\) has density $$ f(x) = \frac{1}{\sqrt{2}\phi} \exp(-\sqrt{2}|x-\mu|/\phi),$$ where \(-\infty < y < \infty\), \(-\infty < \mu < \infty\) and \(\phi > 0\). The mean is \(\mu\) and the variance is \(\phi^2\).

The cumulative distribution function, assumes the form $$ F(x) = \left\{\begin{array}{ll} \frac{1}{2} \exp(\sqrt{2}(x - \mu)/\phi) & x < \mu, \\ 1 - \frac{1}{2} \exp(-\sqrt{2}(x - \mu)/\phi) & x \geq \mu. \end{array}\right.$$

The quantile function, is given by $$ F^{-1}(p) = \left\{\begin{array}{ll} \mu + \frac{\phi}{\sqrt{2}} \log(2p) & p < 0.5, \\ \mu - \frac{\phi}{\sqrt{2}} \log(2(1-p)) & p \geq 0.5. \end{array}\right.$$

References

Kotz, S., Kozubowski, T.J., Podgorski, K. (2001). The Laplace Distributions and Generalizations. Birkhauser, Boston.

Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications, 2nd Ed. Chapman & Hall, Boca Raton.

See Also

Distributions for other standard distributions and rmLaplace for the random generation from the multivariate Laplace distribution.

Examples

Run this code
x <- rlaplace(1000)
## Q-Q plot for Laplace data against true theoretical distribution:
qqplot(qlaplace(ppoints(1000)), x, main = "Laplace Q-Q plot",
  xlab = "Theoretical quantiles", ylab = "Sample quantiles")
abline(c(0,1), col = "red", lwd = 2)

Run the code above in your browser using DataLab