The **gamma function**, denoted Γ(*x*), is commonly employed in a number of statistical distributions. Click here if you are interested in a formal definition which involves calculus, but for our purposes this is not necessary. What is important are the following properties and the fact that Excel provides a function that computes the gamma function (as described below).

- Γ(1) = 1
- Γ(
*x*+ 1) =*x*Γ(*x*) - Γ(
*n*) = (*n*– 1)! For all natural numbers*n*= 0, 1, 2, 3, … - Γ(½) =

**Excel Function**: Excel provides the following function:

**GAMMALN**(*x*) = ln Γ(*x*), i.e. the natural log of the gamma function. Since the inverse of the log function is the exponential function (for more details see Exponentials and Logs and Built-in Excel Functions, and so the gamma function can be expressed by the formula:

Γ(*x*) = EXP(GAMMALN(*x*))

Alternatively the gamma function can be calculated from Excel’s function for the gamma distribution (see Gamma Distribution) as follows:

Γ(*x*) = EXP(-1) / GAMMADIST(1, *x*, 1, FALSE)

Excel 2010/2013 also provide the function **GAMMALN.PRECISE**, which is equivalent to GAMMALN. Excel 2013 provides the function **GAMMA**, where GAMMA(x) = Γ(*x*).

Hello Charles! 😉 may i know what is/are the relation, uses and significance of the gamma function in some statistical distribution especially in Studentized range distribution? Thankyou for your response. 😉

Myra,

The gamma function is used in many distributions, including the t, chi and F distributions.

Since n! is a special case of the gamma function, any distribution which uses the combination function C(n,p) is essentially using the gamma function. This includes the binomial distribution.

The gamma function is also used to compute the Studentized range distribution.

Charles

Good day Sir. Sir i need to know what is the relation and connection of binomial distribution and studentized range distribution? Hoping for your response. More power! 😉

Myra,

If there is a connection, I am not aware of it.

Charles

I see, thank you. however, does the studentized range distribution use the combination function C(n,p)? what part? Again, Thank you Sir.

Myra,

It definitely uses the gamma function. I am not sure whether it uses C(n,p).

Charles

Charles,

How can I calculate the Gamma function of a complex number in Excel 2010? Specifically, I want to calculate a Pearson Type IV distribution for which the normalizing constant involves GammaFunction(m + (nu/2) i), where m and nu are parameters.

Tom

Tom,

Excel doesn’t support complex numbers and so doesn’t have a function to calculate the gamma function. There are ways of calculating such a function Excel, but you will need to do some work. See the following webpage for some ways of performing the calculations

http://math.stackexchange.com/questions/264034/closed-form-expression-for-the-gamma-function-for-complex-numbers-s-aib-with

By the way, I will shortly be adding to the Real Statistics Resource Pack some functions that perform some complex number operations, although I don’t include the gamma function yet.

Charles

why do it appear as NUM! in my worksheet? please explain it

i have equation “Gamma ((m/xi)+1)” but after I make a cell ((m/xi)+1), then use this function =EXP(GAMMALN(cell)) , then it appears as NUM!

You may have an overflow error. Remember that Gamma(x) gets to be very large even for not so large values of x. In your case what is the value of x?

Charles

Hello,

Could you show me how to implement the Gamma Function as a Public User Defined Function in Excel 2010 using VBA Code. It should be very easy.

Thank You

Colm

Colm,

In Excel 2010 the gamma function at x is EXP(GAMMALN(x)).

Charles

thank you very much