The gamma function

The gamma function is a continuous function that interpolates the factorials. It is an interesting mathematical object in its own right, but for students of probability, it appears in the normalizing constant of the gamma density, and recognizing the gamma function is a useful technique for simplifying certain integrals.

Definition

Here it is:

\[ \Gamma(x)=\int_0^\infty z^{x-1}e^{-z}\,\text{d}z,\quad x >0. \]

Pay attention. \(x\) is the argument to the function. It’s treated as a constant. \(z\) is the dummy variable of integration. It doesn’t affect the actual value of the expression, and you can change it to whatever you want: \(y\), \(u\), \(t\), whatever. At the end of the day, the value of the integral is just a number; plug in different \(x\) values, and you get different numbers. That’s the gamma function. Figure 1 displays the picture.

Figure 1

R provides the gamma command for actually computing this:

gamma(0.5) # √π
[1] 1.772454
gamma(1)   # 1
[1] 1
gamma(4)   # 3!
[1] 6
gamma(8)   # 7!
[1] 5040

Properties

You first met the gamma function on Problem Set 0, where you showed that it satisfies the following recursion:

\[ \Gamma(x+1) = x\Gamma(x). \]

That works for any real number \(x>0\). But now let’s say you plug in an integer \(n\geq 2\). As a result of the recursion, something cute happens:

\[ \begin{aligned} \Gamma(n)&=\Gamma(n-1+1)\\ &=(n-1)\Gamma(n-1)\\ &=(n-1)(n-2)\Gamma(n-2)\\ &=(n-1)(n-2)(n-3)\Gamma(n-3)\\ &\vdots\\ &=(n-1)(n-2)(n-3)\cdots 3\cdot2\cdot\Gamma(2)\\ &=(n-1)(n-2)(n-3)\cdots 3\cdot2\cdot1\cdot\Gamma(1)\\ &=(n-1)! \end{aligned} \]

The last line follows because \(\Gamma(1)=\int_0^\infty \exp(-x)\,\textrm{d}x=1\) (shown here, but make sure you can do it yourself). The punchline is that the gamma function is a continuous function that interpolates the factorials. That is, it’s a smooth curve that “connects the dots,” like you see in Figure 1.

The gamma function has many funky properties that have kept mathematicians busy for a long time. For instance, \(\Gamma(1/2)=\sqrt{\pi}\), which you showed on Problem Set 5. If you’re interested, there’s more where that came from.