Learn R Programming

UnivRNG (version 1.2.3)

draw.laplace: Generates variates from Laplace distribution

Description

This function implements pseudo-random number generation for a Laplace (double exponential) distribution with pdf

$$f(x|\lambda,\alpha)=\frac{\lambda}{2}e^{-\lambda|x-\alpha|}$$

for \(\lambda\)>0 where \(\alpha\) and \(\lambda\) are the location and scale parameters, respectively.

Usage

draw.laplace(nrep, alpha, lambda)

Arguments

nrep

Number of data points to generate.

alpha

Location parameter for the desired Laplace distribution.

lambda

Scale parameter for the desired Laplace distribution.

Value

A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.

Examples

Run this code
# NOT RUN {
draw.laplace(nrep=100000, alpha=4, lambda=2)

draw.laplace(nrep=100000, alpha=-5, lambda=4)
# }

Run the code above in your browser using DataLab