2

Stats-ophils,

I am running into a problem, in which I'd like to generate a Gamma distribution (in Julia) and I know the value of the quantile Q(0.9) = 130 as well as the shape parameter k=2.

Is it possible to come up with a function to calculate the shape parameter θ?

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
dmeu
  • 280
  • 2
  • 10

1 Answers1

4

Yes it's possible.

Suppose that $X\sim \mathrm{Gamma}(\alpha, \beta)$ where $\alpha$ is the shape parameter and $\beta$ the scale parameter.

Define the incomplete gamma function as $$ \Gamma(a, z)=\int_{z}^{\infty}t^{a-1}\mathrm{e}^{-t}\;\mathrm{d}t $$

and the generalized incomplete gamma function as $$ \Gamma(a, z_0, z_1)=\int_{z_0}^{z_1}t^{a-1}\mathrm{e}^{-t}\;\mathrm{d}t = \Gamma(a,z_0)-\Gamma(a,z_1). $$

Further, define the generalized regularized/normalized incomplete gamma function as $$ Q(a,z_0,z_1)=\frac{\Gamma(a, z_0, z_1)}{\Gamma(a)} $$ Finally, the inverse gamma regularized/normalized function is the solution for $z_1$ in $s = Q(a, z_0, z_1)$

The $q$-quantile of a Gamma distribution is given by $\beta\;\mathrm{InverseGammaRegularized(\alpha, 0, q)}$. Assuming that the $q$-quantile is $k$, solving for $\beta$ we have $$ \beta = \frac{k}{\mathrm{InverseGammaRegularized(\alpha, 0, q)}} $$ For your example $$ \beta = \frac{130}{\mathrm{InverseGammaRegularized(2, 0, 0.9)}}=33.4214 $$

I'm not sure if this function is implemented in Julia.

COOLSerdash
  • 25,317
  • 8
  • 73
  • 123
  • 1
    Thank you! This helps a lot, understanding-wise. I have meanwhile built a solution based on a linear model fit. I fear that the Inverse Gamma Regularized function is not implemented in Julia.. – dmeu Jul 14 '19 at 09:56