Tutorials › VEE Mathematical Statistics › The MGF of a Gamma Variable

VEE Mathematical Statistics · Moment Generating Functions · Tutorial 232 of 880

The MGF of a Gamma Variable

Learn to derive and use the gamma MGF under either common parameterization, including its domain and the moments recovered from its derivatives.

Intermediate 12 min read

What You'll Learn

  • Write the gamma density under shape-rate and shape-scale parameterizations
  • Derive the MGF using the gamma integral
  • State the exact domain of the gamma MGF
  • Differentiate the MGF to obtain the first and second raw moments
  • Recover the variance and check results against the parameters
  • Avoid confusing the rate with the scale or the second raw moment with the variance

Why the Gamma MGF Needs Careful Parameterization

The gamma distribution is used to model positive quantities such as waiting times, service durations, and claim amounts under specified models. Its moment generating function (MGF) has a compact form, but two parameterizations are common: one uses a rate, and the other uses a scale. Confusing these parameters changes both the formula and the MGF's domain.

This tutorial derives the MGF for both conventions, explains why its domain has a finite upper endpoint, and shows how to recover the mean and variance by differentiation. The focus is on one gamma random variable; no result about sums of gamma variables is needed here.

Definition: A gamma random variable with shape \(\alpha>0\) and rate \(\beta>0\), written \(X\sim\operatorname{Gamma}(\alpha,\beta)\) under the shape-rate convention, has density $$ f_X(x)=\frac{\beta^\alpha}{\Gamma(\alpha)}x^{\alpha-1}e^{-\beta x},\qquad x>0. $$ Here \(\Gamma(\alpha)=\int_0^\infty u^{\alpha-1}e^{-u}\,du\). Under the shape-scale convention, the shape is \(\alpha>0\), the scale is \(\theta>0\), and the density is $$ f_X(x)=\frac{1}{\Gamma(\alpha)\theta^\alpha}x^{\alpha-1}e^{-x/\theta},\qquad x>0. $$ The two conventions describe the same family when \(\theta=1/\beta\).

A rate has units inverse to those of \(X\), whereas a scale has the same units as \(X\). Thus a waiting time measured in hours might have a rate measured per hour or a scale measured in hours. Before substituting into a formula, identify which parameterization is being used.

Deriving the Shape-Rate MGF

The MGF of \(X\) is \(M_X(t)=E[e^{tX}]\), for those real values of \(t\) for which this expectation is finite. For a gamma variable with shape \(\alpha\) and rate \(\beta\), substitute the density into the expectation:

$$ \begin{aligned} M_X(t) &=\int_0^\infty e^{tx}\frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha-1}e^{-\beta x}\,dx\\ &=\frac{\beta^\alpha}{\Gamma(\alpha)} \int_0^\infty x^{\alpha-1}e^{-(\beta-t)x}\,dx. \end{aligned} $$

This integral converges exactly when \(\beta-t>0\), or \(t<\beta\). In that case, set \(u=(\beta-t)x\). Then \(x=u/(\beta-t)\) and \(dx=du/(\beta-t)\), so

$$ \int_0^\infty x^{\alpha-1}e^{-(\beta-t)x}\,dx =\frac{1}{(\beta-t)^\alpha}\int_0^\infty u^{\alpha-1}e^{-u}\,du =\frac{\Gamma(\alpha)}{(\beta-t)^\alpha}. $$

Substitution gives the MGF. The same integral also explains why the endpoint is excluded: at \(t=\beta\), the exponential factor in the integrand is \(1\), and \(\int_0^\infty x^{\alpha-1}\,dx\) diverges. For \(t>\beta\), the exponential factor grows as \(x\) increases, so the integral diverges as well.

Theorem: If \(X\) has a gamma distribution with shape \(\alpha>0\) and rate \(\beta>0\), then $$ M_X(t)=\left(\frac{\beta}{\beta-t}\right)^\alpha =\left(1-\frac{t}{\beta}\right)^{-\alpha},\qquad t<\beta. $$ The MGF is not finite for \(t\geq\beta\).

For shape \(\alpha\) and scale \(\theta\), use \(\beta=1/\theta\). The equivalent expression is

$$ M_X(t)=(1-\theta t)^{-\alpha},\qquad t<\frac{1}{\theta}. $$

Both formulas have \(M_X(0)=1\), as every MGF must: in the rate form, \((\beta/\beta)^\alpha=1\); in the scale form, \((1-0)^{-\alpha}=1\). The domain includes every negative \(t\) and all positive \(t\) below the stated upper endpoint.

Recovering the Mean and Variance

When the MGF exists in an interval containing zero, its first derivative at zero is the mean and its second derivative at zero is the second raw moment. The variance is the second raw moment minus the square of the mean. Differentiate the shape-rate expression:

$$ M_X(t)=\beta^\alpha(\beta-t)^{-\alpha}, \qquad M_X'(t)=\alpha\beta^\alpha(\beta-t)^{-\alpha-1}, $$
$$ M_X''(t)=\alpha(\alpha+1)\beta^\alpha(\beta-t)^{-\alpha-2}. $$

Evaluating at zero gives \(E[X]=\alpha/\beta\) and \(E[X^2]=\alpha(\alpha+1)/\beta^2\). Therefore,

$$ \operatorname{Var}(X) =E[X^2]-(E[X])^2 =\frac{\alpha(\alpha+1)}{\beta^2}-\frac{\alpha^2}{\beta^2} =\frac{\alpha}{\beta^2}. $$

For the shape-scale form, the equivalent moments are \(E[X]=\alpha\theta\) and \(\operatorname{Var}(X)=\alpha\theta^2\). These are useful checks, but the derivative calculation also makes clear which derivative gives which quantity: \(M_X''(0)\) is not the variance.

Worked Example: A Shape-Rate MGF and Its Derivatives

A hypothetical equipment-repair duration \(X\), measured in days, has a gamma distribution with shape \(\alpha=3\) and rate \(\beta=2\) per day. Find its MGF and domain, evaluate it at \(t=1\) per day, and calculate its mean and variance using derivatives. There is no interest-rate or mortality assumption in this duration model.

Method and parameter check. This is the shape-rate convention, so the rate is \(\beta=2\) per day. The density is \(f_X(x)=2^3x^2e^{-2x}/\Gamma(3)\) for \(x>0\).

The MGF formula gives

$$ M_X(t)=\left(\frac{2}{2-t}\right)^3,\qquad t<2\text{ per day}. $$

The requested value is within the domain. Substituting \(t=1\) per day,

$$ M_X(1)=\left(\frac{2}{2-1}\right)^3=2^3=8. $$

To find the moments by differentiation, write \(M_X(t)=8(2-t)^{-3}\). Then

$$ M_X'(t)=24(2-t)^{-4},\qquad M_X''(t)=96(2-t)^{-5}. $$

At zero, \(M_X'(0)=24/16=3/2\) days and \(M_X''(0)=96/32=3\) days squared. Hence

$$ \operatorname{Var}(X)=3-\left(\frac{3}{2}\right)^2 =3-\frac{9}{4}=\frac{3}{4}\text{ days}^2. $$

Check and common mistake. The parameter formulas give mean \(3/2\) days and variance \(3/2^2=3/4\) days squared, matching the derivatives. Also, \(M_X(0)=(2/2)^3=1\). The value \(8\) belongs to \(t=1\), not \(t=0\); substituting zero must always return one.

Using the Shape-Scale Convention

The scale form is convenient when a problem states a characteristic time or amount in the same units as the random variable. Its MGF has the same structure, but the domain endpoint is the reciprocal of the scale. The following example checks the domain, an MGF value, and both moments.

Worked Example: A Shape-Scale Service-Time Model

A hypothetical service time \(X\) has a gamma distribution with shape \(\alpha=3\) and scale \(\theta=4\) hours. State its MGF and domain, evaluate it at \(t=0.1\) per hour, and find the mean and variance. No interest or mortality assumption applies.

Method and parameter check. The scale is \(4\) hours, not a rate of \(4\) per hour. The reciprocal rate is \(\beta=1/4\) per hour. Using the scale form directly,

$$ M_X(t)=(1-4t)^{-3},\qquad t<\frac{1}{4}=0.25\text{ per hour}. $$

Since \(0.1<0.25\), the requested input is in the domain. Substituting,

$$ M_X(0.1)=(1-4(0.1))^{-3} =(1-0.4)^{-3} =0.6^{-3} =\left(\frac{5}{3}\right)^3 =\frac{125}{27}\approx4.6296. $$

For the derivatives, \(M_X'(t)=12(1-4t)^{-4}\) and \(M_X''(t)=192(1-4t)^{-5}\). Thus \(E[X]=M_X'(0)=12\) hours and \(E[X^2]=M_X''(0)=192\) hours squared. The variance is

$$ \operatorname{Var}(X)=192-12^2=192-144=48\text{ hours}^2. $$

Check and common mistake. The shape-scale formulas confirm \(E[X]=3(4)=12\) hours and \(\operatorname{Var}(X)=3(4^2)=48\) hours squared. The upper endpoint is \(1/4=0.25\) per hour, not \(4\) per hour. The reciprocal is required because \(t\) has units inverse to \(X\).

Domain Checks and Units

A finite MGF value can be used only at an input strictly below the rate, or strictly below the reciprocal scale. This is not merely an algebraic restriction: outside the domain, the defining expectation is infinite. Always compare \(t\) with the endpoint before evaluating the formula.

Worked Example: Testing Inputs Against a Rate Domain

A hypothetical processing time \(X\), measured in days, has a gamma distribution with shape \(\alpha=4\) and rate \(\beta=0.5\) per day. Determine whether \(t=-0.2\), \(t=0.1\), and \(t=0.6\), each measured per day, are in the MGF domain. Evaluate the MGF at \(t=0.1\) and obtain the mean and variance. There is no interest or mortality assumption.

Method. The rate form gives

$$ M_X(t)=\left(\frac{0.5}{0.5-t}\right)^4,\qquad t<0.5\text{ per day}. $$

The domain test is a strict inequality. Since \(-0.2<0.5\), the first input is allowed. Since \(0.1<0.5\), the second is allowed. Since \(0.6\not<0.5\), the third is not allowed, and the MGF is infinite there.

At \(t=0.1\),

$$ M_X(0.1)=\left(\frac{0.5}{0.5-0.1}\right)^4 =\left(\frac{0.5}{0.4}\right)^4 =\left(\frac{5}{4}\right)^4 =\frac{625}{256} \approx2.4414. $$

The mean is \(\alpha/\beta=4/0.5=8\) days, and the variance is \(\alpha/\beta^2=4/(0.5)^2=4/0.25=16\) days squared. Equivalently, \(M_X''(0)=\alpha(\alpha+1)/\beta^2=4(5)/0.25=80\), and \(80-8^2=16\).

Check and common mistake. \(M_X(0)=(0.5/0.5)^4=1\), and the derivative-based second-moment calculation agrees with the parameter variance. Do not replace the domain endpoint \(0.5\) by its reciprocal: the stated parameter is already the rate, so the condition is \(t<0.5\) per day.

Common Errors to Avoid

  • Swapping rate and scale. Under shape-rate, \(M_X(t)=(\beta/(\beta-t))^\alpha\) and \(t<\beta\). Under shape-scale, \(M_X(t)=(1-\theta t)^{-\alpha}\) and \(t<1/\theta\).
  • Allowing the endpoint. The condition is strict. At \(t=\beta\), or \(t=1/\theta\), the defining integral diverges.
  • Reporting the second raw moment as the variance. First calculate \(M_X''(0)=E[X^2]\), then subtract \((M_X'(0))^2\).
  • Ignoring units. If \(X\) is measured in hours, the input \(t\) and rate \(\beta\) are per hour; a scale \(\theta\) is in hours.
  • Failing the normalization check. Substitution at \(t=0\) must give \(M_X(0)=1\). A different result usually signals an algebra or parameterization error.
Key takeaway: For a gamma variable with shape \(\alpha\), the shape-rate MGF is \((1-t/\beta)^{-\alpha}\) for \(t<\beta\), while the shape-scale MGF is \((1-\theta t)^{-\alpha}\) for \(t<1/\theta\). Differentiation at zero gives mean \(\alpha/\beta=\alpha\theta\) and variance \(\alpha/\beta^2=\alpha\theta^2\).

Check Your Understanding

For each problem, identify the parameterization before using a formula. Answers are given at the end of each item.

  1. A hypothetical call-center resolution time has a gamma distribution with shape \(2\) and rate \(3\) per hour. State the MGF and its domain, then give the mean and variance. (Answer: \(M_X(t)=(3/(3-t))^2\) for \(t<3\) per hour; mean \(2/3\) hour; variance \(2/9\) hour squared.)
  2. A hypothetical inspection duration has shape \(5\) and scale \(2\) minutes. Find the MGF domain, evaluate \(M_X(0.25)\), and calculate the mean and variance. (Answer: \(t<0.5\) per minute; \(M_X(0.25)=32\); mean \(10\) minutes; variance \(20\) minutes squared.)
  3. A positive laboratory processing time has shape \(3\) and rate \(4\) per hour. State its domain, evaluate \(M_X(1)\), and find \(E[X]\) and \(\operatorname{Var}(X)\). (Answer: \(t<4\) per hour; \(M_X(1)=64/27\); mean \(3/4\) hour; variance \(3/16\) hour squared.)
  4. A hypothetical loss amount follows a gamma distribution with shape \(4\) and scale \(3\) thousand dollars. Is \(t=0.4\) per thousand dollars in the MGF domain? Regardless of that input, give the mean and variance. (Answer: No, because the domain is \(t<1/3\) per thousand dollars; mean \(12\) thousand dollars; variance \(36\) thousand-dollars squared.)
  5. A gamma variable has mean \(6\) hours and variance \(18\) hours squared. Determine its shape and rate, then state its MGF and domain. (Answer: shape \(\alpha=2\), rate \(\beta=1/3\) per hour; \(M_X(t)=(1-3t)^{-2}\) for \(t<1/3\) per hour.)
Clinical Biostats