There are several things in math and statistics named gamma. Three examples are

- the gamma
**function** - the gamma
**constant** - the gamma
**distribution**

This post will show how these are related. We’ll also look at the **incomplete** gamma function which connects with all the above.

## The gamma function

The **gamma function** is the most important function not usually found on a calculator. It’s the first “advanced” function you’re likely to learn about. You might see it in passing in a calculus class, in a homework problem on integration by parts, but usually not there’s not much emphasis on it. But it comes up a **lot **in application.

You can think of the gamma function as a way to extend factorial to non-integer values. For non-negative integers *n*, Γ(*n* + 1) = *n*!.

(Why is the argument *n* + 1 to Γ rather than *n*? There are a number of reasons, historical and practical. Short answer: some formulas turn out simpler if we define Γ that way.)

## The gamma constant

The **gamma constant**, a.k.a. **Euler’s constant** or the **Euler-Mascheroni constant**, is defined as the asymptotic difference between harmonic numbers and logarithms. That is,

The constant γ comes up fairly often in applications. But what does it have to do with the gamma *function*? There’s a reason the constant and the function are both named by the same Greek letter. One is that the gamma *constant* is part of the product formula for the gamma *function*.

If we take the logarithm of this formula and differentiation we find out that

## The gamma distribution

If you take the integrand defining the gamma *function* and turn it into a probability distribution by normalizing it to integrate to 1, you get the **gamma distribution**. That is, a gamma random variable with shape *k* has probability density function (PDF) given by

More generally you could add a scaling parameter to the gamma distribution in the usual way. You could imaging the scaling parameter present here but set to 1 to make things simpler.

## The incomplete gamma function

The **incomplete gamma function** relates to everything above. It’s like the (complete) gamma function, except the range of integration is finite. So it’s now a function of two variables, the extra variable being the limit of integration.

(Note that now *x* appears in the limit of integration, not the exponent of *t*. This notation is inconsistent with the definition of the (complete) gamma function but it’s conventional.)

It uses a lower case gamma for its notation, like the gamma *constant*, and is a generalization of the gamma *function*. It’s also essentially the cumulative distribution function of the gamma *distribution*. That is, the CDF of a gamma random variable with shape *s* is γ(*s*, *x*) / Γ(s).

The function γ(*s*, *x*) / Γ(s) is called the **regularized** incomplete gamma function. Sometimes the distinction between the regularized and unregularized versions is not explicit. For example, in Python, the function `gammainc`

does not compute the incomplete gamma function per se but the *regularized* incomplete gamma function. This makes sense because the latter is often more convenient to work with numerically.

Nice post!

You may also want to clarify that the incomplete gamma function has two parts:

1) Lower incomplete gamma function with limits 0 to x. This uses the lowercase letter for gamma.

2) Upper incomplete gamma function with limits from x to infinity. This uses the uppercase letter for gamma.

You have defined #1 as the incomplete gamma function. However, some systems such as Mathematica define the incomplete gamma function as #2. In other words, the Mathematica function Gamma[s, x] is the upper incomplete gamma function.

“The gamma function is the most important function not usually found on a calculator.”

This isn’t completely fair; many calculators have a factorial function that is actually gamma(x + 1) (i. e., it works if you put a non-integer value into it).

Taking a totally unrelated tangent, the expsum for today (8Nov2018) reminds me of a ring oscillator, with the expected odd number of inverters.

Do you know why the gamma function is used more often to describe and extension of the factorial function to complex numbers than the pi function? I always thought it was weird that I was taught that n! is Gamma (n+1). It’s even weirder once I found out that n! is Pi (n).

The gamma function is essentially the unique extension of factorial that is log-convex. See the Bohr-Mollerup theorem.