rgamma_c | R Documentation |
Returns a sample from a gamma-distributed random variable. The function uses the Marsaglia-Tsang fast gamma method used to generate the random samples. See more details below. The name was chosen so it doesn't clash with R's native method.
rgamma_c(n, b = 2, a = 1/2)
n |
(int) |
b |
(numeric) - shape parameter. Must be in the range |
a |
(numeric) - scale parameter. Must be in the range |
The gamma distribution is given by the function:
f(x) = \frac{1}{\Gamma(b)a^b}x^{b-1}e^{-x/a}, x > 0
where b
is a shape parameter and a
is a scale parameter.
The RNG is given by Marsaglia and Tsang, "A Simple Method for
generating gamma variables", ACM Transactions on Mathematical
Software, Vol 26, No 3 (2000), p363-372.
Available at \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1145/358407.358414")}.
The code is based on the original 'GSL' version, adapted to
use 'R' version of RNGs. All credits to the original authors.
Implemented by J.D.Lamb@btinternet.com, minor modifications for 'GSL'
by Brian Gough. Adapted to 'R' by Elias Haddad.
a numeric vector containing a random sample with above parameters.
sample_gamma <- rgamma_c(1000, 1, 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.