In order to calculate the expected value, we substitute zero into the first derivative of the moment generating function.
In order to caclulate the variance, we substitute zero into the second derivative of the moment generating function and then subtract the expected value squared.
\[ \binom{n}{k}=\frac{n!} {(n-k)!k!} \]
\[ Probability|Mass|Function = \binom{n}{k} *p^k * (1-p)^{n-k} \]
\[M(t) =\sum_{x = 0}^{n} e^{tx} \binom{n}{x} p^x (1-p)^{n-x}\]
\[M(t) =\sum_{x = 0}^{n} \binom{n}{x} (pe^t)^x (q)^{n-x}\] \[ = (pe^t + q)^n \]
\[ M'(t) = n(pe^t+q)^{n-1}pe^t \] We now substitute zero into the above first derivative
\[ E(X) = M'(0) = n(pe^0+q)^{n-1}pe^0 \] \[ E(X) = np \]
\[ M''(0) = n(n-1)p^2+np \] We now subtract the square of the expected value that we calculated above
\[ V(X) = M''(0) - (E(X))^2\] \[ V(X) = n(n-1)p^2+np - (np)^2\]
\[ V(X) = np^2(n-1)+np - (np)^2\] \[ V(X) = n^2p^2-np^2+np - n^2p^2\] \[ V(X) = np-np^2 \] \[ V(X) = np(1-p) \]
Since PDF is \(\lambda e^{−λx}\) :
\[\left[M(t) = \int_{0}^{\infty} e^{tx}\lambda e^{−λx} dx\right]\] \[\left[= \lambda \int_{0}^{\infty} e^{(t-\lambda)x} dx\right]\] \[=\left. \lambda \frac{e^{(t-\lambda)x}}{t-\lambda} \right|_{0}^{\infty}\] \[ = \frac {\lambda}{(\lambda-t)} \]
\[ M'(t) = \frac {\lambda}{(\lambda-t)^2} \]
We now substitute zero into the above first derivative
\[ E(X) = M'(0) = \frac {\lambda}{(\lambda-0)^2} \]
\[ E(X) = \frac{\lambda}{\lambda^2} = \frac{1}{\lambda} \]
\[ M''(t) = \frac {2\lambda}{(\lambda-t)^3} \] \[ M''(0) = \frac {2\lambda}{(\lambda-0)^3} \] \[ M''(0) = \frac {2}{\lambda^2} \] We now subtract the square of the expected value that we calculated above
\[ V(X) = M''(0) - (E(X))^2\]
\[ V(X) = \frac {2}{\lambda^2} - (\frac{1}{\lambda})^2\] \[ V(X) = \frac{1}{\lambda^2}\]