Learn R Programming

greybox (version 0.3.0)

dlaplace: Laplace Distribution

Description

Density, cumulative distribution, quantile functions and random generation for the Laplace distribution with the location parameter mu and Mean Absolute Error (or Mean Absolute Deviation) equal to b.

Usage

dlaplace(q, mu = 0, b = 1, log = FALSE)

plaplace(q, mu = 0, b = 1)

qlaplace(p, mu = 0, b = 1)

rlaplace(n = 1, mu = 0, b = 1)

Arguments

q

vector of quantiles.

mu

vector of location parameters (means).

b

vector of mean absolute errors.

log

if TRUE, then probabilities are returned in logarithms.

p

vector of probabilities.

n

number of observations. Should be a single number.

Value

Depending on the function, various things are returned (usually either vector or scalar):

  • dlaplace returns the density function value for the provided parameters.

  • plaplace returns the value of the cumulative function for the provided parameters.

  • qlaplace returns quantiles of the distribution. Depending on what was provided in p, mu and b, this can be either a vector or a matrix, or an array.

  • rlaplace returns a vector of random variables generated from the Laplace distribution. Depending on what was provided in mu and b, this can be either a vector or a matrix or an array.

Details

When mu=0 and b=1, the Laplace distribution becomes standardized with. The distribution has the following density function:

f(x) = 1/(2b) exp(-abs(x-mu) / b)

References

Examples

Run this code
# NOT RUN {
x <- dlaplace(c(-1000:1000)/10, 0, 1)
plot(x, type="l")

x <- plaplace(c(-1000:1000)/10, 0, 1)
plot(x, type="l")

qlaplace(c(0.025,0.975), 0, c(1,2))

x <- rlaplace(1000, 0, 1)
hist(x)

# }

Run the code above in your browser using DataLab