Learn R Programming

power4mome (version 0.1.1)

runif_rs: Random Variable From a Uniform Distribution

Description

Generate random numbers from a uniform distribution, with user-specified population mean and standard deviation.

Usage

runif_rs(n = 10, min = 0, max = 1, pmean = 0, psd = 1)

Value

A vector of the generated random numbers.

Arguments

n

The number of random numbers to generate.

min

min for runif.

max

max for runif.

pmean

Population mean.

psd

Population standard deviation.

Details

First, the user specifies the parameters, min and max, and the desired population mean and standard deviation. Then the random numbers will be generated and rescaled with the desired population mean and standard.

Examples

Run this code
set.seed(90870962)
x <- runif_rs(n = 5000,
              min = 2,
              max = 4,
              pmean = 3,
              psd = 1)
mean(x)
sd(x)
hist(x)

Run the code above in your browser using DataLab