Learn R Programming

gmatrix (version 0.3)

gdgamma: The Gamma Distribution

Description

Density, and random generation for the Gamma distribution with parameters shape and scale.

Usage

gdgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE, type = "d") grgamma(n, shape, rate = 1, scale = 1/rate, type = "d")

Arguments

x
vector of quantiles
n
number of random values to return
shape,scale
shape and scale parameters. Must be positive, scale strictly
rate
an alternative way to specify the scale
log
logical; if TRUE, probabilities/densities p are returned as log(p)
type
specify the type; may be "double", "single" (or short form "d" or "s")

Value

gdgamma gives the density and grgamma generates random deviates.

Details

Works in much the same way as the R base functions.

References

Random gamma simulation was implemented using the algorithm described in: Marsaglia and Tsang (2000) A Simple Method for Generating Gamma Variables. ACM Transactions on Mathematical Software. Volume 26 Issue 3, Pages 363-372.

See Also

dgamma

Examples

Run this code
myRndNums = grgamma(10, c(1,2))

Run the code above in your browser using DataLab