gammainc {expint}R Documentation

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.

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.

Value

The value of the incomplete gamma function.

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

Note

The C implementation is based on code from the GNU Software Library https://www.gnu.org/software/gsl/.

Author(s)

Vincent Goulet vincent.goulet@act.ulaval.ca

References

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

See Also

expint

Examples

## 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)

[Package expint version 0.1-8 Index]