rpgnorm_rs: Random Variable From a Generalized Normal Distribution

View source: R/rpgnorm_rs.R

rpgnorm_rsR Documentation

Random Variable From a Generalized Normal Distribution

Description

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

Usage

rpgnorm_rs(n = 10, p = 2, pmean = 0, psd = 1)

Arguments

n

The number of random numbers to generate.

p

The parameter of the distribution. Must be a positive non-zero number. Default is 2, resulting in a normal distribution. Higher than 2 results in negative excess kurtosis. Lower than 2 results in positive excess kurtosis.

pmean

Population mean.

psd

Population standard deviation.

Details

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

Value

A vector of the generated random numbers.

Examples

set.seed(90870962)
x <- rpgnorm_rs(n = 5000,
                p = 2,
                pmean = 0,
                psd = 1)
mean(x)
sd(x)
hist(x)
x_kurt <- function(p) {gamma(5/p)*gamma(1/p)/(gamma(3/p)^2) - 3}

p <- 6
x <- rpgnorm_rs(n = 50000,
                p = p,
                pmean = 0,
                psd = 1)
mean(x)
sd(x)
x_kurt(p)
qqnorm(x); qqline(x)

p <- 1
x <- rpgnorm_rs(n = 50000,
                p = p,
                pmean = 0,
                psd = 1)
mean(x)
sd(x)
x_kurt(p)
qqnorm(x); qqline(x)

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