Learn R Programming

Rsubbotools (version 0.0.1)

ralaplace: Generates an Asymmetric Laplace-distributed sample

Description

Returns a sample from an Asymmetric Laplace distribution.

Usage

ralaplace(n, m = 0, al = 1, ar = 1)

Value

a numeric vector containing a random sample.

Arguments

n

(int) - the size of the sample.

m

(numeric) - the location parameter.

al, ar

(numeric) - left and right scale parameters, respectively.

Details

The Asymmetric Laplace distribution is given by the two-sided exponential distribution given by the function: $$f(x;a_l,a_r,m) = \frac{1}{A} e^{-|\frac{x-m}{a_l}| }, x < m $$ $$f(x;a_l,a_r,m) = \frac{1}{A} e^{-|\frac{x-m}{a_r}| }, x > m $$ with: $$A = a_l + a_r$$ The random sampling is done by inverse transform sampling.

Examples

Run this code
sample_gamma <- ralaplace(1000)

Run the code above in your browser using DataLab