Learn R Programming

power4mome (version 0.1.1)

rt_rs: Random Variable From a t Distribution

Description

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

Usage

rt_rs(n = 10, df = 5, pmean = 0, psd = 1)

Value

A vector of the generated random numbers.

Arguments

n

The number of random numbers to generate.

df

df for stats::rt().

pmean

Population mean.

psd

Population standard deviation.

Details

First, specify the parameter df and the desired population mean and standard deviation. The random numbers, drawn from the generalized normal distribution by stats::rt(), will then be rescaled with the desired population mean and standard.

Examples

Run this code
set.seed(90870962)
x <- rt_rs(n = 5000,
           df = 5,
           pmean = 3,
           psd = 1)
mean(x)
sd(x)
hist(x)

Run the code above in your browser using DataLab