Incomplete Gamma Function
For MPFR version >= 3.2.0, the following MPFR library function is provided:
mpfr_gamma_inc(a,x)
, the R interface of which is igamma(a,x)
, where
igamma(a,x)
is the “upper” incomplete gamma function
Γ(a,x) :=: Γ(a) - γ(a,x),
where
γ(a,x) := ∫₀ˣ tᵃ⁻¹ e⁻ᵗ dt,
and hence
Γ(a,x) := ∫ (x..∞) tᵃ⁻¹ e⁻ᵗ dt,
and
Γ(a) := γ(a, ∞).
As R's pgamma(x,a)
is
\code{pgamma(x, a)} := γ(a,x) / Γ(a),
we get
igamma(a,x) == gamma(a) * pgamma(x, a, lower.tail=FALSE)
igamma(a, x, rnd.mode = c("N", "D", "U", "Z", "A"))
a numeric vector of “common length”, recyling along a
and x
.
R interface: Martin Maechler
NIST Digital Library of Mathematical Functions, section 8.2. https://dlmf.nist.gov/8.2.i
Wikipedia (2019). Incomplete gamma function; https://en.wikipedia.org/wiki/Incomplete_gamma_function
## show how close pgamma() is : x <- c(seq(0,20, by=1/4), 21:50, seq(55, 100, by=5)) if(mpfrVersion() >= "3.2.0") { print( all.equal(igamma(Const("pi", 80), x), pgamma(x, pi, lower.tail=FALSE) * gamma(pi), tol=0, formatFUN = function(., ...) format(., digits = 7)) #-> 3.13e-16 ) ## and ensure *some* closeness: stopifnot(exprs = { all.equal(igamma(Const("pi", 80), x), pgamma(x, pi, lower.tail=FALSE) * gamma(pi), tol = 1e-15) }) } # only if MPFR version >= 3.2.0
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.