Learn R Programming

genscore (version 1.0.2.2)

rexp_truncated: Generates translated and truncated exponential variables.

Description

Generates translated and truncated exponential variables.

Usage

rexp_truncated(n, lo, hi)

Value

n random variables from the translated truncated exponential distribution.

Arguments

n

An integer, the number of samples to return.

lo

A double, the lower limit of the distribution, cannot be -Inf.

hi

A double, the upper limit of the distribution.

Details

Returns n random variables from the translated truncated exponential distribution with density \(\exp(-(x-lo))/(1-\exp(lo-hi))\) on [lo,hi].

Examples

Run this code
hist(rexp_truncated(1e4, 0, Inf), breaks=200)
hist(rexp_truncated(1e4, 10, 12), breaks=200)
hist(rexp_truncated(1e4, -2, 2), breaks=200)
hist(rexp_truncated(1e4, -10, 0), breaks=200)
hist(rexp_truncated(1e4, -100, Inf), breaks=200)
hist(rexp_truncated(1e4, -100, -95), breaks=200)

Run the code above in your browser using DataLab