rexp_rs: Random Variable From an Exponential Distribution

View source: R/rexp_rs.R

rexp_rsR Documentation

Random Variable From an Exponential Distribution

Description

Generate random numbers from an exponential distribution, rescaled to have user-specified population mean and standard deviation.

Usage

rexp_rs(n = 10, rate = 1, pmean = 0, psd = 1, rev = FALSE)

Arguments

n

The number of random numbers to generate.

rate

rate for stats::rexp().

pmean

Population mean.

psd

Population standard deviation.

rev

If TRUE, the distribution is revered to generate a negatively skewed distribution. Default is FALSE.

Details

First, specify the parameter, rate, and the desired population mean and standard deviation. The random numbers, drawn from an exponential distribution by stats::rexp(), will then be rescaled with the desired population mean and standard.

Value

A vector of the generated random numbers.

Examples

set.seed(90870962)
x <- rexp_rs(n = 5000,
             rate = 4,
             pmean = 3,
             psd = 1)
mean(x)
sd(x)
hist(x)


power4mome documentation built on Sept. 9, 2025, 5:35 p.m.