rpower: Generates a random sample from a Exponential Power...

View source: R/RcppExports.R

rpowerR Documentation

Generates a random sample from a Exponential Power distribution

Description

Returns a sample from a gamma-distributed random variable.

Usage

rpower(n, m = 0, a = 1, b = 2)

Arguments

n

(int) - size of the sample.

m

(numeric) - the location parameter.

a

(numeric) - scale parameter.

b

(numeric) - shape parameter.

Details

The exponential power distribution (EP) is given by the function:

f(a,b) = \frac{1}{2a\Gamma(1+1/b)}e^{-|x/a|^b}, -\infty < x < \infty

. where b is a shape parameter, a is a scale parameter and \Gamma representes the gamma function. While not done here, the distribution can be adapted to have non-zero location parameter. The Exponential Power distribution is related to the gamma distribution by the equation:

E = a*G(1/b)^{1/b}

where E and G are respectively EP and gamma random variables. This property is used for cases where b<1 and b>4. For 1 \leq b \leq 4 rejection methods based on the Laplace and normal distributions are used, which should be faster. Technical details about this algorithm are available on: P. R. Tadikamalla, "Random Sampling from the Exponential Power Distribution", Journal of the American Statistical Association, September 1980, Volume 75, Number 371, pages 683-686. The code is based on the original 'GSL' version, adapted to use 'R' version of RNGs by Elias Haddad. All credits to the original authors.

Value

a numeric vector containing a random sample with above parameters.

Examples

sample_gamma <- rpower(1000)

Rsubbotools documentation built on April 16, 2025, 5:10 p.m.