Gamma Function (and its Natural Logarithm)

DESCRIPTION:
Returns the gamma function or the log of the gamma function.

USAGE:
gamma(x)
lgamma(x)

REQUIRED ARGUMENTS:
x:
numeric or complex object.
Missing values (NA) are allowed.

VALUE:
gamma or natural log of gamma function evaluated for each value in x.

CLASSES:
This function will be used as the default method for classes that do not inherit a specifc method for the function or for the Math group of functions. The result will retain the class and the attributes. If this behavior is not appropriate, the designer of the class should provide a method for the function or for the Math group.

DETAILS:
NAs are returned when evaluation would cause numerical problems, except that when an overflow occurs, an infinity is returned.

These are members of the Math group of generic functions.


WARNING:
gamma(x) increases very rapidly with x. Use lgamma to avoid overflow.

BACKGROUND:
For positive integral values, gamma(x) is (x-1)!. For negative integral values, gamma(x) is undefined.

NOTE:
See family for the family generating function Gamma used with the glm and gam functions. See GAMMA for the functions related to the gamma distribution: dgamma (density), pgamma (probability), qgamma (quantile), rgamma (sample).

SEE ALSO:
exp , sum , cumsum .

EXAMPLES:
gamma(6)   # same as 5 factorial
lgamma(20) # natural log of gamma(20)