# Gamma Function

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) = 1
2. Γ(x + 1) = x Γ(x)
3. Γ(n) = (n – 1)! For all natural numbers n = 0, 1, 2, 3, …
4. Γ(½) = $\! \sqrt{\pi}$

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).

### 13 Responses to Gamma Function

1. Myra Villaflor Gutierrez says:

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. 😉

• Charles says:

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

• Myra Villaflor Gutierrez says:

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! 😉

• Charles says:

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

• Myra Villaflor Gutierrez says:

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

• Charles says:

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

2. Tom Keelin says:

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

3. zamzam says:

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!

• Charles says:

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

4. Colm Dougan says:

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

• Charles says:

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

5. farshad says:

thank you very much