gammaVer: Gamma Function Versions

View source: R/dgamma.R

gammaVerR Documentation

Gamma Function Versions

Description

Provide different variants or versions of computing the Gamma (\Gamma) function.

Usage


gammaVer(x, version, stirlerrV = c("R3", "R4..1", "R4.4_0"), traceLev = 0L)

Arguments

x

numeric vector of absissa value for the Gamma function.

version

integer in {1,2,..,5} specifying which variant is desired.

stirlerrV

a string, specifying the stirlerr() version/variant to use.

traceLev

non-negative integer indicating the amount of diagnostic “tracing” output to the console during computation.

Details

All of these are good algorithms to compute \Gamma(x) (for real x), and indeed correspond to the versions R's implementation of gamma(x) over time. More specifically, the current version numbers correspond to

  1. . TODO

  2. .

  3. .

  4. Used in R from ... up to versions 4.3.z

  5. Possibly to be used in R 4.4.z and newer.

The stirlerrV must be a string specifying the version of stirlerr() to be used:

"R3":

the historical version, used in all R version up to R 4.3.z.

"R4..1":

only started using lgamma1p(n) instead of lgamma(n + 1.) in stirlerr(n) for n \le 15, in the direct formula.

"R4.4_0":

uses 10 cutoffs instead 4, and these are larger to gain accuracy.

Value

numeric vector as x

Author(s)

Martin Maechler

References

.... TODO ....

See Also

gamma(), R's own Gamma function.

Examples

xx <- seq(-4, 10, by=1/2)
gx <- sapply(1:5, gammaVer, x=xx)
gamx <- gamma(xx)
cbind(xx, gx, gamma=gamx)
apply(gx, 2, all.equal, target=gamx, tol = 0) # typically: {T,T,T,T, 1.357e-16}
stopifnot( apply(gx, 2, all.equal, target = gamx, tol = 1e-14))
                                                 # even 2e-16 (Lnx, 64b, R 4.2.1)

DPQ documentation built on Nov. 3, 2024, 3 a.m.