gamma
Gamma Function (and Its Derivatives and Logarithm)

Description

Describes the special mathematics function gamma and its derivatives and logarithma.

Usage

gamma(x) 
lgamma(x)
digamma(x)
trigamma(x)
psigamma(x, deriv = 0) 

Arguments

x
  • for gamma and lgamma, a numeric or complex object.
  • for digamma, a numeric or complex value, or a vector.
  • For trigamma, a numeric or complex value, or a vector. It can be real or complex, but it must have a positive real part.
Missing values (NA) are allowed.

Details

gamma and lgamma: For more details about the gamma function, see http://en.wikipedia.org/wiki/Gamma_function.
digamma, trigamma and psigamma: gamma, lgamma, digamma and trigamma are members of the Math group of generic functions.
NAs are returned when evaluation would cause numerical problems, except that when an overflow occurs, an infinity is returned.
Value
gammareturns the gamma function evaluated for each value in x.
lgammareturns natural log of the gamma function evaluated for each value in x.
digammareturns the derivative of the log gamma function evaluated for each value in x.
trigammareturns the second derivative of the log gamma function evaluated for each value in x.
psigammareturns the (deriv+1)-th derivative of the log gamma function evaluated for each value in x.
Classes
gamma is used as the default method for classes that do not inherit a specific method for the function or for the Math group of functions. The result retains 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.
References
Abramowitz, M., and Stegun, I. A. (Eds.). (1965). Handbook of Mathematical Functions. New York: Dover.
Venables, W. N. and Ripley, B. D. (1997). Modern Applied Statistics with S-PLUS, Second Ed. New York: Springer.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole. (For gamma and lgamma.)
Abramowitz, M. and Stegun, I. A. (1972) Handbook of Mathematical Functions. New York: Dover. Chapter 6: Gamma and Related Functions.
http://en.wikipedia.org/wiki/Gamma_function.
http://en.wikipedia.org/wiki/Beta_function.
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
Special, GAMMA, family, exp, sum, cumsum
Examples
gamma(6)   # same as 5 factorial 
(gamma(5+1.0e-6)-gamma(5))/1.0e-6/gamma(5)  # Gives: 1.506119

lgamma(20) # natural log of gamma(20) (lgamma(5+1.0e-6)-lgamma(5))/1.0e-6 # Gives: 1.506118

digamma(6) # derivative digamma(5) # Gives: 1.506118

trigamma(6)# second derivative

x <- seq(1, 2, .1) matrix(c(x, trigamma(x)), ncol=2) identical(digamma(x), psigamma(x, 0)) # Gives: TRUE identical(trigamma(x), psigamma(x, 1)) # Gives: TRUE

Package base version 6.0.0-69
Package Index