Moment generating function for finding mean and variance $$f_X(x)=\left\{\begin{matrix}
2e^{-2(x-1)} &x\geq1 \\ 
 0&otherwise 
\end{matrix}\right.$$
How can i find the mean and variance by first getting the moment generating function and using it to find them.
 A: The key here is to have a bit of an understanding of the MGF.
Suppose $X$ is a random variable with MGF $M_X(t)$. By definition,
$$
M_X(t):=\mathbb{E}[e^{tX}].
$$
But, let's think about this for a moment.  In terms of power series,
$$
e^{tX}=\sum_{n=0}^{\infty}\frac{(tX)^n}{n!}=1+tX+\frac{1}{2}t^2X^2+\frac{1}{6}t^3X^3\cdots
$$
Computing the expectation (and sweeping a couple of important details under the rug) gives
$$
M_X(t)=\mathbb{E}[e^{tX}]=1+\mathbb{E}[X]t+\frac{1}{2}\mathbb{E}[X^2]t^2+\frac{1}{6}\mathbb{E}[X^3]t^3+\cdots
$$
This is why this is called the moment generating function -- it is quite literally the exponential generating function for the sequence of moments of the random variable!
With this in mind, we can use usual power series tricks to come up with the first couple of moments; namely,
$$
M_X'(t)=\mathbb{E}[X]+\mathbb{E}[X^2]t+\frac{1}{2}\mathbb{E}[X^3]t^2+\cdots
$$
implies that $M_X'(0)=\mathbb{E}[X]$.
Taking a further derivative, we get
$$
M_X''(t)=\mathbb{E}[X^2]+\mathbb{E}[X^3]t+\cdots
$$
and therefore $M_X''(0)=\mathbb{E}[X^2]$.
Now that you have the first two moments, you can use $\text{Var}[X]=\mathbb{E}[X^2]-\mathbb{E}[X]^2$ to compute the variance easily.
A: Let $M(s)$ be the Moment Generating Function. Then $\mathbb{E}[X]$ is directly found from $M'(0)$, and also $\mathbb{E}[X^2]$ is also found from $M''(0)$. Then you can find the Variance from there. 
