Learn R Programming

deamer (version 1.0)

laplace: Laplace distribution

Description

density and random generation for the Laplace distribution of mean 'mu' and scale parameter 'b'

Usage

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

Arguments

x
vector of quantiles.
n
number of observations.
mu
mean. Should be a single value. Defaults to 0.

b
scale. Should be a single value. Defaults to 1.

Value

Returns a vector of n draws from a Laplace distribution

Details

The Laplace density function is parameterized as: $$\frac{1}{2b}exp\Big(-\frac{|x-\mu|}{b}\Big)$$

Examples

Run this code
set.seed(1234)

n=1000
x <- rchisq(n,3)
b=0.4
e <- rlaplace(n, 0, b)
y <- x + e  #noisy observations with laplace noise

Run the code above in your browser using DataLab