| gammaVer | R Documentation |
Provide different variants or versions of computing the Gamma
(\Gamma) function.
gammaVer(x, version, stirlerrV = c("R3", "R4..1", "R4.4_0"), traceLev = 0L)
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 |
traceLev |
non-negative integer indicating the amount of diagnostic “tracing” output to the console during computation. |
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
. TODO
.
.
Used in R from ... up to versions 4.3.z
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.
numeric vector as x
Martin Maechler
.... TODO ....
gamma(), R's own Gamma function.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.