rlaplace: Generate Random Variables from the Laplace Distribution

View source: R/rlaplace.R

rlaplaceR Documentation

Generate Random Variables from the Laplace Distribution

Description

Generates random samples from the Laplace (double exponential) distribution with location parameter 0 and scale parameter b.

The probability density function is

f(x)=\frac{1}{2b}\exp\left(-\frac{|x|}{b}\right),

where b>0 is the scale parameter.

Random numbers are generated using the inverse transform method.

Usage

rlaplace(n, b = 1)

Arguments

n

An integer specifying the number of observations to generate.

b

A positive numeric value specifying the scale parameter of the Laplace distribution. The default value is 1.

Details

If X \sim Laplace(0,b), then

E(X)=0,

and

Var(X)=2b^2.

This function is used internally by the Laplace Factor Model (LFM) package for generating Laplace-distributed error terms.

Value

A numeric vector of length n containing random observations from the Laplace distribution.

Examples

set.seed(123)

x <- rlaplace(1000)

mean(x)
var(x)

hist(x,
     breaks = 30,
     main = "Laplace Random Sample",
     xlab = "x")


LFM documentation built on June 10, 2026, 5:06 p.m.

Related to rlaplace in LFM...