# Find mean and variance of random variable using moment generating function

Suppose $X \sim U(a,b)$. Find the mean and variance of $X$.

I tried to solve the exercise by computing the moment generating function and then substitute 0 to the ts but it doesn't work. How should I solve it?

Edit: This is what I've done so far:
$m'_x(t)$ = $\frac{be^{tb} - ae^{ta} - (b-a)(e^{tb} - e^{ta})}{(t(b-a))^2}$

if I do $m'_x(0)$ substituting $0$s to the $t$s, I get $EX = 0$ and I don't think it's the right way to do it.

What should I do?

• Could you explain how substituting zero would yield both a mean and a variance? – whuber Feb 28 '18 at 16:02
• Also, maybe show us what you have done so far? – Daniel Feb 28 '18 at 16:03
• How do you deal with the fact that substituting $t=0$ in your expression yields $0$ in the denominator? – whuber Feb 28 '18 at 16:20
• That's why I'm asking, I don't think that EX = 0 is the right answer – Zhang_anlan Feb 28 '18 at 16:26
• Are you familiar with taking limits? – Mark L. Stone Feb 28 '18 at 16:36