rlaplace_truncated {genscore} | R Documentation |
Generates laplace variables truncated to a finite union of intervals.
Description
Generates laplace variables truncated to a finite union of intervals.
Usage
rlaplace_truncated(n, lefts, rights, m = 0, s = 1)
Arguments
n |
An integer, the number of samples to return. |
lefts |
A vector of numbers, must have the same length as |
rights |
A vector of numbers, must have the same length as |
m |
A number, the location parameter of the laplace distribution. |
s |
A number, the scale/dispersion parameter of the laplace distribution. |
Details
Returns n
random variables from the truncated laplace distribution with density proportional to \exp(-|x-m|/s)
truncated to the domain defined by the union of [lefts[i]
, rights[i]
].
Value
n
random variables from the truncated laplace distribution.
Examples
hist(rlaplace_truncated(1e4, -Inf, Inf), breaks=200)
hist(rlaplace_truncated(1e4, c(0, 5), c(2, Inf), m=2, s=3), breaks=200)
hist(rlaplace_truncated(1e4, c(-Inf, 0, 3), c(-3, 1, 12), m=8, s=4), breaks=200)
hist(rlaplace_truncated(1e4, c(-5, 0), c(-2, 2), s=0.8), breaks=200)
hist(rlaplace_truncated(1e4, c(-10, 1), c(-7, 10), m=-4), breaks=200)
hist(rlaplace_truncated(1e4, c(-Inf, 100), c(-100, Inf), m=100), breaks=200)
hist(rlaplace_truncated(1e4, c(-Inf, 100), c(-100, Inf), m=-100), breaks=200)
hist(rlaplace_truncated(1e4, c(-100, -90), c(-95, -85), s=2), breaks=200)