Von a mathforum post:
k Lassen Sie die positive Null der digamma Funktion bezeichnen, etwa 1,461632 ...
c = Sqrt (2 * pi)/e - Gamma (k) ...
... Leading L (x) = ln ((x + c)/Sqrt (2 * Pi)), die Umkehrung meiner Gamma Approximation ist
ApproxInvGamma oder AIG (x) = L (x)/W (L (x)/e) + 1/2.
k <- 1.461632
cc <- sqrt(2*pi)/exp(1)-gamma(k)
L <- function(x) {
log((x+cc)/sqrt(2*pi))
}
AIG <- function(x) {
Lx <- L(x)
Lx/(emdbook::lambertW(Lx*exp(-1))) + 1/2
}
par(las=1,bty="l")
curve(1-AIG(gamma(x))/x,from=2,to=20,
ylab="relative error of approximation")
Alternativ können Sie verwenden uniroot()
:
AIG(5)
ufun <- function(x=5) {
uniroot(function(z) gamma(z)-x,c(1.00001,10))$root
}
ufun(5) ## 3.852341
AIG(5) ## 3.848149
Vielleicht nicht einfach: http://math.stackexchange.com/questions/18362/is-there-an-inverse-gamma-gamma -1-z-Funktion (obwohl diese Frage eine Umkehrung über die komplexen Zahlen ist). Auch http://mathforum.org/kb/message.jspa?messageID=342551&tstart=0, die eine Möglichkeit gibt, ein * ungefähres * inverses Gamma zu implementieren. –