# How come i can't compute the expected value using the MGF for uniform distribution?

I thought that $M^r(0) = E[X^r]$, but for a uniform distribution the MGF is $\dfrac{e^{bt}-e^{at}}{(b-a)t}$, so there already is a singularity at $t=0$. So it would seem $M'(0) \neq E[X]$

Why is that?

-

Hint: There is no problem at $0$, it just looks as if there might be. The singularity at $t=0$ is removable, and once we have removed it the mgf has a nice power series. Expand the exponentials in the numerator of the mgf in power series, using the ordinary series expansion of $e^x$.

The front terms are each $1$, and cancel. Then you can divide by $t$, and have the power series expansion of the mgf. From this you can read off the moments.

Remark: Once we have obtained the mgf, we hardly ever use repeated differentiation to find the moments. Most often, it is series expansion, adapting our knowledge of standard series.

Added: Using $e^{ct}=1+ct+\frac{c^2 t^2}{2}+\frac{c^3t^3}{6}+\cdots$, we find that the mgf is $$\frac{1}{b-a}\left(\frac{\left(1+bt+\frac{b^2t^2}{2}+\frac{b^3t^3}{6}+\cdots\right)- \left(1+at+\frac{a^2t^2}{2}+\frac{a^3t^3}{6}+\cdots\right)}{t}\right).$$ Simplify, cancelling the $t$. We get $$\frac{1}{b-a}\left(b-a +\frac{b^2-a^2}{2}t+\frac{b^3-a^3}{6}t^2+\cdots \right).$$ The coefficient of $t$ is $\dfrac{1}{b-a}\dfrac{b^2-a^2}{2}$, which simplifies to $\dfrac{a+b}{2}$.

Alternately, differentiate the series term by term, then set $t=0$.

-
Why do I have to write it out as a series? I took the derivative of the whole thing and it's telling me I can't plug in 0. I could expand it, and then plug t = 0, but that would just give me an approxmiation – Hawk Dec 2 '12 at 1:15
@sizz: It would give you the exact answer, not an approximation. Once yo have done the division by $t$, you just want the coefficient of $t$. Or equivalently you can differentiate the series term by term, put $t=0$. Most of the series dies. If you wish I can do the details in the answer, it is quite short. – André Nicolas Dec 2 '12 at 1:25
Oh I see what you mean. Despite the singular point, the function is analytic. Interesting – Hawk Dec 2 '12 at 2:08