3

I am building a stats/probability library in python and right now I am working on the properties of the gamma distribution. I know that its quantile function (F^-1(x)) does not have a nice closed-form solution, so I am trying to find a numerical method that gives a good approximation. As I'm using the gamma distribution for bayesian statistics, I'm using the rate parameterisation, in case that detail is useful.

Can anybody suggest a method with < 10^-6 error bounds?

PS: Is there a subfield of numerical methods specifically for statistics? I am struggling to find resources online.

PS2: I dug up an old algorithm that can approximate the quantiles of a chi-square function and then convert them to a gamma, but this gamma is parameterised with scale. I am not sure how to do convert it to a gamma parameterised w/ rate.

  • The scale parameter is the inverse of the rate parameter, so that should pose you no difficulty. – Glen_b Jan 05 '20 at 20:56

1 Answers1

2

I think that if one is simply interested in a quantile function, it can look it up through the CDF. And if you are working in Python, that is directly available through the scipy.special module. It includes the Gamma distribution cumulative distribution function parametrised by the rate parameter under the function gdtr(), the inverse of gdtr in respect to x, a (here denoting rate) and b (here denoting shape) are also available through the functions gdtrix, gdtria and gdtrib respectively.

If in need of something more specialised, one may want to check the functions gammainc() and gammaincinv() for the regularized lower incomplete gamma function and the inverse of it. So for example we have:

>>> gdtr(0.4, 3, 2.0) # rate, shape, x
0.047422596071490235
>>> gammainc(3, 2.0*0.4) # If it was scale we would divide.
0.047422596071490235

Regarding your side-question: The field you are inquiring about it not really Statistics but rather Numerical Analysis. The C++ Boost library (which effectively what scipy is following) has some references on Incomplete Gamma Functions if you wish to read this further. A first reference to look into would be Temme (1979) The Asymptotic Expansion of the Incomplete Gamma Functions in SIAM Journal on Mathematical Analysis.

usεr11852
  • 44,125