GammaDist
The Gamma Distribution

Description

Calculates density, cumulative probability, quantile, and generate random sample for the gamma distribution (continuous).

Usage

dgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE) # density
pgamma(q, shape, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) # probability
qgamma(p, shape, rate = 1, scale = 1/rate, lower.tail = TRUE, log.p = FALSE) # quantile
rgamma(n, shape, rate = 1, scale = 1/rate) # random

Arguments

x, q numeric vectors in the range [0, Inf) that specify the quantiles.
p a numeric vector in the range [0, 1] that specifies the probabilities.
n an integer scalar in the range [0, Inf) that specifies the number of random samples requested. If the input value is not an integer, it is truncated. If length(n) is greater than 1, the random function returns length(n) random samples.
shape a numeric vector in the range [0, Inf) that specifies the shape parameter.
rate a numeric vector in the range [0, Inf) that specifies the inverse of the scale parameter.
scale a numeric vector in the range [0, Inf) that specifies the scale parameter. Ignored if rate is supplied.
log a logical value. If FALSE (default), the density function returns the density itself. If TRUE, it returns the log of the density.
lower.tail a logical value. If TRUE (default), the probability supplied to the quantile function or returned by the probability function is P[X <= x]. If FALSE, it is P[X > x].
log.p a logical value. If FALSE (default), the probability supplied to the quantile function or returned by the probability function is the probability itself. If TRUE, it is the log of the probability.

Details

The distribution parameter(s) are replicated cyclically to be the same length as the input x, q, p, or the number of random samples requested.
Missing values (NAs) in the input or the distribution parameter(s) will cause the corresponding elements of the result to be missing.
Value
returns density (dgamma), cumulative probability (pgamma), quantile (qgamma), or random sample (rgamma) for the gamma distribution with parameters shape and scale (or alternatively rate).
Side Effects
If the .Random.seed dataset exists, the random sample function updates its value. The random sample function creates the .Random.seed dataset if it does not exist.
Background
The gamma distribution is a family of continuous probability distributions defined on the interval [0, Inf) and parameterized by two positive parameters, shape and scale (or alternatively rate, the inverse of scale).
Note
For information about the family generating function gamma used with the glm and gam functions, see family.
For information about the gamma function, see gamma.
References
Johnson, N. L. and Kotz, S. 1970. Continuous Univariate Distributions, Volume 1. Boston, MA: Houghton-Mifflin.
Kotz, S. and Johnson, N. L. (Eds.) . Gamma Distribution. Encyclopedia of Statistical Sciences.
See Also
Chisqare, Exponential, family, gamma, set.seed
Examples
# sample of 20 with shape parameter 10
rgamma(20, 10)

# the probability that a value from the gamma # distribution with shape 1.5 is less than 1.2 pgamma(1.2, 1.5)

# compute a vector of quantiles (x <- qgamma(seq(.001, .999, len = 10), 1.5))

# density for shape 1.5 dgamma(x, 1.5)

Package stats version 6.1.4-13
Package Index