Gamma Distribution

DESCRIPTION:

Density, cumulative probability, quantiles and random generation for the gamma distribution.

USAGE:

dgamma(x, shape, rate=1, scale, log=FALSE)
pgamma(q, shape, rate=1, scale, lower.tail=TRUE, log.p=FALSE)
qgamma(p, shape, rate=1, scale)
rgamma(n, shape, rate=1, scale, bigdata=FALSE)

REQUIRED ARGUMENTS:

x
vector or bdVector of (positive) quantiles. Missing values ( NAs) are allowed.
q
vector or bdVector of (positive) quantiles. Missing values ( NAs) are allowed.
p
vector or bdVector of probabilities. Missing values ( NAs) are allowed.
n
sample size. If length(n) is larger than 1, then length(n) random values are returned.
shape
shape parameter (> 0). This is replicated to be the same length as p or q or the number of deviates generated.

OPTIONAL ARGUMENTS:

rate
inversely proportional to the mean of the distribution; often called lambda. The mean of the distribution is shape/ rate, the variance is shape/ rate^2, and the skewness is 2/sqrt(shape).
scale
alternate parameterization, the inverse of rate, often called beta. If scale is supplied and rate is not, then rate = 1/scale. This is ignored if rate is supplied.
bigdata
a logical value; if TRUE, an object of type bdVector is returned. Otherwise, a vector object is returned. This argument can be used only if the bigdata library section has been loaded.
log
a logical scalar; if TRUE, dgamma will return the log of the density, not the density itself.
lower.tail
a logical scalar; if TRUE, pgamma(x) will return P(X<=x), otherwise P(X>x).
log.p
a logical scalar; if TRUE, pgamma will return the log of the probability, not the probability itself.

VALUE:

density ( dgamma), probability ( pgamma), quantile ( qgamma), or random sample ( rgamma) for the gamma distribution with shape shape.

SIDE EFFECTS:

The function rgamma causes creation of the dataset .Random.seed if it does not already exist, otherwise its value is updated.

DETAILS:

Elements of q or p that are missing will cause the corresponding elements of the result to be missing.

BACKGROUND:

The gamma distribution takes values on the positive real line. Special cases of the gamma are the exponential distribution and the chi-squared distributions (see Exponential and Chisquare). Applications of the gamma include queuing theory, inventory control and precipitation processes.

For shape less than 10^8 pgamma(q,shape) is computed using formulae 6.5.31 and 6.5.32 of Abramowitz and Stegun (1970). For these values of shape dgamma is computed based on the lgamma function. For larger values of shape pgamma and dgamma use a normal approximation, adjusted for skewness only. See formulae 26.2.48 and 26.1.32 of Abramowitz and Stegun. There may be slight discontinuities in higher derivatives at shape==10^8.

For details on the uniform random number generator implemented in S-PLUS, see the set.seed help file.

REFERENCES:

Johnson, N. L. and Kotz, S. (1970). Continuous Univariate Distributions, vol. 1. Houghton-Mifflin, Boston.

Gamma Distribution. In Encyclopedia of Statistical Sciences. S. Kotz and N. L. Johnson, eds.

NOTE:

See family for the family generating function Gamma used with the glm and gam functions. See gamma for the gamma function.

SEE ALSO:

, , , , .

EXAMPLES:

rgamma(20,10) # sample of 20 with shape parameter 10 
pgamma(1.2, 1.5) # the probability that a value from the gamma 
                 # distribution with shape 1.5 is less than 1.2 
x <- qgamma(seq(.001, .999, len = 100), 1.5) # compute a vector of quantiles 
# be sure that you have an open graphics window 
plot(x, dgamma(x, 1.5), type = "l") # density plot for shape 1.5