For a model (1) I needed to calculate the cumulative distribution function \(F(x)\) of the Gamma distribution. There is no uniform consensus: the Gamma distribution has different parametrizations. I use the \(k, \theta\) parametrization from (2). This would yield (3):
\[F(x) = \gamma( \frac{x}{\theta},k)\] |
where \(\gamma(x,a)\) is the incomplete Gamma function defined by:
\[\gamma(x,a) = \frac{1}{\Gamma(a)} \int_0^x t^{a-1}e^{-t} dt\] |
The function \(\Gamma(x)\) is the (complete) Gamma function:
\[\Gamma(x) = \int_0^{\infty} t^{x-1} e^{-t} dt \] |
Unfortunately there a few alternative definitions of the incomplete Gamma function. In (2) the following definition is used:
\[\gamma(s,x) = \int_0^x t^{s-1} e^{-t} dt\] |
So watch out: different definitions are being used.
As a result we can implement the CDF of the Gamma distribution with parameter \(k\) and \(\theta\) as follows (2):
GammaReg(x/theta,k)
There is also a more obscure way to calculate this using an extrinsic function. The syntax is unfortunately needlessly complicated and the documentation is really, really bad (4).
scalars |
References
- Modeling Flood Damages, http://yetanothermathprogrammingconsultant.blogspot.com/2017/07/modeling-flood-damages.html
- Gamma Distribution, https://en.wikipedia.org/wiki/Gamma_distribution
- New Special Functions in GAMS, http://www.amsterdamoptimization.com/pdf/specfun.pdf
- Stochastic Library, https://www.gams.com/latest/docs/userguides/userguide/_u_g__extrinsic_functions.html#UG_ExtrinsicFunctions_StochasticLibrary