rpower | R Documentation |
Returns a sample from a gamma-distributed random variable.
rpower(n, m = 0, a = 1, b = 2)
n |
(int) - size of the sample. |
m |
(numeric) - the location parameter. |
a |
(numeric) - scale parameter. |
b |
(numeric) - shape parameter. |
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.
a numeric vector containing a random sample with above parameters.
sample_gamma <- rpower(1000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.