rbeta_rs: Random Variable From a Beta Distribution

View source: R/rbeta_rs.R

rbeta_rsR Documentation

Random Variable From a Beta Distribution

Description

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

Usage

rbeta_rs(n = 10, shape1 = 0.5, shape2 = 0.5, pmean = 0, psd = 1)

Arguments

n

The number of random numbers to generate.

shape1

shape1 for stats::rbeta().

shape2

shape2 for stats::rbeta().

pmean

Population mean.

psd

Population standard deviation.

Details

First, specify the two parameters, shape1 and shape2, and the desired population mean and standard deviation. The random numbers, drawn from a beta distribution by stats::rbeta() will then be rescaled with the desired population mean and standard deviation.

Value

A vector of the generated random numbers.

Examples

set.seed(90870962)
x <- rbeta_rs(n = 5000,
              shape1 = .5,
              shape2 = .5,
              pmean = 3,
              psd = 1)
mean(x)
sd(x)
hist(x)


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