Learn R Programming

Runuran (version 0.40)

udgamma: UNU.RAN object for Gamma distribution

Description

Create UNU.RAN object for a Gamma distribution with parameters shape and scale.

[Distribution] -- Gamma.

Usage

udgamma(shape, scale=1, lb=0, ub=Inf)

Value

An object of class "unuran.cont".

Arguments

shape

(strictly positive) shape parameter.

scale

(strictly positive) scale parameter.

lb

lower bound of (truncated) distribution

ub

upper bound of (truncated) distribution

Author

Josef Leydold and Wolfgang H\"ormann unuran@statmath.wu.ac.at.

Details

The Gamma distribution with parameters shape \(=\alpha\) and scale \(=\sigma\) has density $$ f(x) = \frac{1}{{\sigma}^{\alpha}\Gamma(\alpha)} {x}^{\alpha-1} e^{-x/\sigma} $$ for \(x \ge 0\), \(\alpha > 0\) and \(\sigma > 0\). (Here \(\Gamma(\alpha)\) is the function implemented by R's gamma() and defined in its help.)

The domain of the distribution can be truncated to the interval (lb,ub).

References

N.L. Johnson, S. Kotz, and N. Balakrishnan (1994): Continuous Univariate Distributions, Volume 1. 2nd edition, John Wiley & Sons, Inc., New York. Chap. 17, p. 337.

See Also

unuran.cont.

Examples

Run this code
## Create distribution object for gamma distribution
distr <- udgamma(shape=4)
## Generate generator object; use method PINV (inversion)
gen <- pinvd.new(distr)
## Draw a sample of size 100
x <- ur(gen,100)

Run the code above in your browser using DataLab