rlnorm_rs: Random Variable From a Lognormal Distribution

View source: R/rlnorm_rs.R

rlnorm_rsR Documentation

Random Variable From a Lognormal Distribution

Description

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

Usage

rlnorm_rs(n = 10, mui = 0, sigma = 1, rev = FALSE, pmean = 0, psd = 1)

Arguments

n

The number of random numbers to generate.

mui

The parameter mui to be used by stats::rlnorm().

sigma

The parameter sigma to be used by stats::rlnorm().

rev

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

pmean

Population mean.

psd

Population standard deviation.

Details

First, specify the parameter, mui and sigma, and the desired population mean and standard deviation. The random numbers, drawn from a lognormal distribution by stats::rlnorm(), will then be rescaled with the desired population mean and standard.

Value

A vector of the generated random numbers.

Examples

set.seed(90870962)
x <- rlnorm_rs(n = 5000,
               mui = 0,
               sigma = 1,
               pmean = 0,
               psd = 1)
mean(x)
sd(x)
hist(x)


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