St · Statistics & Probability

Why Can’t I Compute the Expected Value from a Uniform MGF?

Updated 13 October 2026

At a glance

  1. 1. Find the MGF

    Integrate e to the power tX over the uniform distribution’s support.

  2. 2. Define It at Zero

    The formula has a removable 0/0 at t = 0; the MGF itself equals 1 there.

  3. 3. Differentiate at Zero

    The expected value is the derivative of the MGF evaluated at zero.

  4. 4. Use the Limit

    Expand the exponential or take a limit before substituting t = 0.

If you try to substitute t=0t=0 into the usual MGF formula for a continuous uniform distribution, you get a fraction with both numerator and denominator equal to zero. That does not mean the MGF fails or that you cannot use it to find the mean. The formula is written in a form that is undefined at zero, even though the MGF itself is well defined there.

For X∼Uniform⁡(a,b)X\sim\operatorname{Uniform}(a,b), the expected value is the derivative of the MGF at zero:

E[X]=MX′(0)=a+b2.\mathbb{E}[X]=M_X'(0)=\frac{a+b}{2}.

The MGF of a continuous uniform variable

The moment-generating function is defined by MX(t)=E[etX]M_X(t)=\mathbb{E}[e^{tX}]. For a uniform distribution on [a,b][a,b], the density is 1/(b−a)1/(b-a) throughout that interval, so

MX(t)=1b−a∫abetx dx=etb−etat(b−a),t≠0.\begin{aligned} M_X(t) &=\frac{1}{b-a}\int_a^b e^{tx}\,dx\\ &=\frac{e^{tb}-e^{ta}}{t(b-a)},\qquad t\ne 0. \end{aligned}

At t=0t=0, use the definition instead: MX(0)=E[e0]=1M_X(0)=\mathbb{E}[e^0]=1. This is also the limit of the displayed formula as tt approaches zero. Since a uniform variable on a finite interval is bounded, its MGF exists for every real tt.

The mean comes from differentiating the MGF and then evaluating at zero—not from evaluating the MGF itself at zero. In general, MX′(0)=E[X]M_X'(0)=\mathbb{E}[X] when the MGF exists in a neighborhood of zero.

Why direct substitution seems to fail

The numerator etb−etae^{tb}-e^{ta} becomes 1−1=01-1=0 at t=0t=0, while the denominator t(b−a)t(b-a) also becomes zero. Thus, the formula for t≠0t\ne 0 has the indeterminate form 0/00/0 at that one point. You cannot substitute zero into that quotient and expect a value.

Instead, expand the exponentials near zero:

etb−eta=(b−a)t+b2−a22t2+⋯=(b−a)t+(b−a)(a+b)2t2+⋯ .\begin{aligned} e^{tb}-e^{ta} &=(b-a)t+\frac{b^2-a^2}{2}t^2+\cdots\\ &=(b-a)t+\frac{(b-a)(a+b)}{2}t^2+\cdots. \end{aligned}

Dividing by t(b−a)t(b-a) gives

MX(t)=1+a+b2t+⋯ .M_X(t)=1+\frac{a+b}{2}t+\cdots.

The coefficient of tt is the derivative at zero, so MX′(0)=(a+b)/2M_X'(0)=(a+b)/2. The same expansion shows why the apparent singularity disappears: as tt approaches zero, the quotient approaches 11, agreeing with MX(0)=1M_X(0)=1.

Worked example: X∼Uniform⁡(2,5)X\sim\operatorname{Uniform}(2,5)

Here,

MX(t)=e5t−e2t3t,t≠0.M_X(t)=\frac{e^{5t}-e^{2t}}{3t},\qquad t\ne 0.

Substituting t=0t=0 into this expression produces 0/00/0. Expand the numerator instead:

e5t=1+5t+252t2+⋯ ,e2t=1+2t+2t2+⋯ .\begin{aligned} e^{5t}&=1+5t+\frac{25}{2}t^2+\cdots,\\ e^{2t}&=1+2t+2t^2+\cdots. \end{aligned}

Subtract and divide by 3t3t:

MX(t)=3t+212t2+⋯3t=1+72t+⋯ .M_X(t)=\frac{3t+\frac{21}{2}t^2+\cdots}{3t} =1+\frac{7}{2}t+\cdots.

Therefore, MX′(0)=7/2=3.5M_X'(0)=7/2=3.5. This agrees with the midpoint of the interval, (2+5)/2=3.5(2+5)/2=3.5. You can also check it directly from the uniform density: the mean is 13∫25x dx=3.5\frac{1}{3}\int_2^5 x\,dx=3.5.

If you mean a discrete uniform distribution

For a variable equally likely to be any integer from mm through nn, inclusive, the MGF is a finite sum:

MX(t)=1n−m+1∑k=mnetk.M_X(t)=\frac{1}{n-m+1}\sum_{k=m}^{n}e^{tk}.

Differentiate the sum and set t=0t=0. Each term contributes kk, so the result is the average of the integers from mm to nn:

E[X]=m+n2.\mathbb{E}[X]=\frac{m+n}{2}.

The same principle applies: differentiate the MGF first, then evaluate at zero. The continuous and discrete formulas differ, but neither distribution prevents you from using the MGF.

Common mistakes

  • Setting t=0t=0 in the quotient too early. The quotient formula is for t≠0t\ne 0; use a limit or series to handle zero.
  • Confusing MX(0)M_X(0) with the mean. The MGF at zero is always 11. Its first derivative at zero gives the mean.
  • Differentiating a numerically unstable expression near zero. The closed-form derivative can involve cancellation between nearly equal quantities. For calculations close to zero, a series expansion or the integral definition is often more reliable.
  • Assuming the MGF does not exist. A continuous uniform variable on a finite interval has a finite MGF for every real tt; the issue is only the displayed formula’s removable singularity at zero.

References

  1. A First Course in Probability — Sheldon Ross

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.