Learn R Programming

Rsubbotools (version 0.0.1)

rlaplace: Generates a Laplace-distributed sample

Description

Returns a sample from a Laplace-distributed random variable.

Usage

rlaplace(n, m = 0, a = 1)

Value

a numeric vector containing a random sample with above parameters.

Arguments

n

(int) - the size of the sample.

m

(numeric) - the location parameter.

a

(numeric) - the scale parameter.

Details

The Laplace distribution is given by the two-sided exponential distribution given by the function: $$ f(x;a,m) = \frac{1}{2a} e^{- \left| \frac{x-m}{a} \right|} $$ The random sampling is done by inverse transform sampling.

Examples

Run this code
sample_gamma <- rlaplace(1000, 0, 1)

Run the code above in your browser using DataLab