R/inv_digamma.R

Defines functions inv_digamma

inv_digamma = function(y,niter=5){
# % INV_DIGAMMA    Inverse of the digamma function.
# %
# % inv_digamma(y) returns x such that digamma(x) = y.

#% never need more than 5 iterations

#% Newton iteration to solve digamma(x)-y = 0
x = exp(y)+1/2;
i = which(y <= -2.22);
x[i] = -1/(y[i] - digamma(1));

for (iter in 1:niter){ x = x - (digamma(x)-y)/trigamma(x);}

return(x)
}

Try the xLLiM package in your browser

Any scripts or data that you put into this service are public.

xLLiM documentation built on Nov. 2, 2023, 5:17 p.m.