Learn R Programming

expint (version 0.1-6)

gammainc: Incomplete Gamma Function

Description

The incomplete gamma function \(\Gamma(a, x)\).

Usage

gammainc(a, x)

Arguments

a

vector of real numbers.

x

vector of non-negative real numbers.

Value

The value of the incomplete gamma function.

Invalid arguments will result in return value NaN, with a warning.

Details

As defined in 6.5.3 of Abramowitz and Stegun (1972), the incomplete gamma function is $$ \Gamma(a, x) = \int_x^\infty t^{a-1} e^{-t}\, dt$$ for \(a\) real and \(x \ge 0\).

For non-negative values of \(a\), we have $$ \Gamma(a, x) = \Gamma(a) (1 - P(a, x)),$$ where \(\Gamma(a)\) is the function implemented by R's gamma() and \(P(a, x)\) is the cumulative distribution function of the gamma distribution (with scale equal to one) implemented by R's pgamma().

Also, \(\Gamma(0, x) = E_1(x)\), \(x > 0\), where \(E_1(x)\) is the exponential integral implemented in expint.

References

Abramowitz, M. and Stegun, I. A. (1972), Handbook of Mathematical Functions, Dover.

See Also

expint

Examples

Run this code
# NOT RUN {
## a > 0
x <- c(0.2, 2.5, 5, 8, 10)
a <- 1.2
gammainc(a, x)
gamma(a) * pgamma(x, a, 1, lower = FALSE) # same

## a = 0
a <- 0
gammainc(a, x)
expint(x)                                 # same

## a < 0
a <- c(-0.25, -1.2, -2)
sapply(a, gammainc, x = x)
# }

Run the code above in your browser using DataLab