Article 42GWK Gamma gamma gamma!

Gamma gamma gamma!

by
John
from John D. Cook on (#42GWK)

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.

ggg_function.svg

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

(Why is the argument n + 1 to I rather than n? There are a number of reasons, historical and practical. Short answer: some formulas turn out simpler if we define I 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,

ggg_constant.svg

The constant I^3 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.

ggg_product.svg

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

ggg_psi1.svg

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

ggg_pdf.svg

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.

ggg_inc.svg

(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 I^3(s, x) / I(s).

The function I^3(s, x) / I(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.

Related postsreF8XO3Q0tk
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments