Tuesday, January 19, 2016

Special functions: Incomplete gamma functions


All the elements presented are not warranted to be correct or free from defects. 
Please report any errors found to  afstblogs@gmail.com


The terminology used in literature for the incomplete gamma functions, also called regularized or normalized can be deceiving. In fact there are four "variations" of the function shown in the table below which brings some surprises when comparing results obtained from different applications. For example, when translating code from FORTRAN to BASIC it is quite common to find the former returning upper tails.



In this blog the references to the incomplete gamma function mean the incomplete gamma ratio function.


Excel Gamma distribution pdf




NOTE: It can be found, for example in SPSS manual, the expression of the  Gamma distribution with the parameter β on the numerator. Of course the results obtained are the same being the value of the parameter the inverse between the two expressions. The problem is to use one of the formulas with the β value appropriate for the other.

The incomplete gamma gamma ratio function can be calculated as a particular case of the Gamma cdf distribution (β=1).  We consider only the incomplete gama ratio lower tail since the other can be easily computed from it.  


Excel formulas and user defined functions



' Incomplete gamma ratio function
Function xlGAMMAINC(x, a)
  With WorksheetFunction
    xlGAMMAINC = .Gamma_Dist(x, a, 1, 1)
  End With
End Function



Matlab



>> gammainc(0.5,0.2)
ans =
    0.8788

 >> gammainc(0.5,0.2,'upper')
ans =
    0.1212

>> gammainc(0.5,0.2)+gammainc(0.5,0.2,'upper')
ans =
     1

>> gammainc(0.5,0.2)*gamma(0.2)
ans =
    4.0343




1 comment:

  1. Hello. I recently sent you an email asking for references for the methods you use to implement the calculate values for the incomplete Gamma functions. Did you receive it?

    ReplyDelete

Note: Only a member of this blog may post a comment.