Learn R Programming

Rsubbotools (version 0.0.1)

rpower: 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)

Value

a numeric vector containing a random sample with above parameters.

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\) represents 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.

Examples

Run this code
sample_gamma <- rpower(1000)

Run the code above in your browser using DataLab