The moment-generating function (or mgf) is probably better understood if you simply focus on its name rather than its formula. It’s a function that generates moments. Of course it helps to know what “moments” are. A moment is a term from mechanics for the product of a distance and its weight. If you have several distances and associated weights, you can calculate all the products and sum them and get what you call the “first moment about the origin.” If that’s a little too abstract, just know that the calculation of the “first moment about the origin” is the same calculation one uses to find the mean of a random variable. Thus the mean of a random variable is the same as the first moment about the origin. Therefore we can use the mgf to generate the first moment about the origin, and thus find the mean of a random variable. But the moment-generating function doesn’t stop there. It also generates second moments, third moments, etc., provided the mgf exists (a detail I’m not going to address in this post). Since the variance of a random variable can be calculated using the first and second moments about the origin, we can use the mgf to find variance as well as the mean.
So that’s the big idea: the moment-generating function provides another (sometimes easier) way to find the mean and variance of a random variable. That’s why it’s taught in upper-level statistics (even though many instructors dive into this topic without providing any motivation for it). Recall the usual formulas for finding the mean and variance: and . These can lead to some awfully long and hard math, especially for finding the variance. Even the variance “shortcut” can get bogged down in finding . This is where the moment-generating function can be of service. Let’s introduce it (for discrete random variables):
I’ll admit it doesn’t look very friendly. And it’s certainly not obvious that it would help you find the mean and variance of a distribution. Why it works is a topic for another post,
a post I’ll almost certainly never write. But seriously, why the mgf does what it does is explained rather well in one of my favorite Dover books, Principles of Statistics by M.G. Bulmer. A highly recommended book at only $15. But say you believe me and take it on faith that the mgf can help us find the mean and variance. How does it work? Well, here are the steps you usually follow:
- find the mgf
- find the first derivative of the mgf
- find the second derivative of the mgf
- solve the first derivative of the mgf for t=0. That gives you the mean.
- solve the second derivative of the mgf for t=0. That gives you
- subtract the mean squared from (ie, use the formula )
Let’s do a simple example. Say we have a probability mass function (pmf) with . (You can verify it’s a pmf by calculating and , and adding the results. They sum to 1.) Use the moment-generating function to find the mean and variance.
Following the steps above we first find the mgf:
Next find the first and second derivatives:
Now solve to find the mean:
Finally solve to find the variance:
Of course you wouldn’t normally employ the mgf for a simple distribution like this, but I thought it was a nice way to illustrate the concepts of the moment-generating function. By the way, I took this example from the textbook Probability and Statistical Inference (7th ed) by Hogg and Tanis (p. 101). Another highly recommended book.