| rlaplace | R Documentation |
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.
rlaplace(n, b = 1)
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 |
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.
A numeric vector of length n containing random observations from
the Laplace distribution.
set.seed(123)
x <- rlaplace(1000)
mean(x)
var(x)
hist(x,
breaks = 30,
main = "Laplace Random Sample",
xlab = "x")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.