[Math] Finding the Variance of a Geometric R.V. using the Moment Generating Function

probabilityprobability distributions

Problem:
Let $X$ be a geometric r.v. with parameter $p$. Find the variance of $X$ using the fact that the moment generating function for $X$ is $M_x(t) = \frac{pe^t}{1 – qe^{t}} $.
Answer:
\begin{eqnarray*}
M_x'(t) &=& \frac{(1 – qe^{t})pe^t – pe^t(-qe^t) } { (1 – qe^{t})^2} \\
M_x'(t) &=& \frac{(1 – qe^{t})pe^t + pqe^{2t} } { (1 – qe^{t})^2} \\
M_x'(t) &=& p(1 – qe^{t})^{-1}e^t + pq(1 – qe^{t})^{-2}e^{2t} \\
M_x''(t) &=& p(1-qe^t)^{-1}e^t – p(1 – qe^t)^{-2}(-qe^t)e^t \\
&+& 2pq(1 – qe^{t})^{-2}e^{2t} – 2pq(1 – qe^{t})^{-3}e^{2t} \\
\sigma^2 &=& M_x''(0) \\
M_x''(0) &=& p(1-q)^{-1} – p(1-q)^{-2}(-q) + 2pq(1-q)^{-2} – 2pq(1-q)^{-3} \\
M_x''(0) &=& p(p)^{-1} + pq(p)^{-2} + 2pq(p)^{-2} – 2pq(p)^{-3} \\
M_x''(0) &=& 1 +\frac{q}{p} + 2q(p)^{-1} – 2q(p)^{-2} \\
M_x''(0) &=& 1 +\frac{q}{p} + \frac{2q}{p} – \frac{2q}{p^2} \\
M_x''(0) &=& 1 + \frac{3q}{p} – \frac{2q}{p^2} = \frac{p^2 + 3pq – 2q}{p^2} \\
M_x''(0) &=& \frac{p^2 + 3p(1-p) – 2(1-p)}{p^2}
= \frac{p^2 + 3p – 3p^2 -2 + 2p}{p^2} \\
M_x''(0) &=& \frac{-2p^2 + 5p – 2}{p^2} \\
\sigma^2 &=& \frac{-2p^2 + 5p – 2}{p^2} \\
\end{eqnarray*}
However, the variance of a geometric r.v. is $\frac{1 – p}{p^2}$. What did I do wrong?
Thanks,
Bob

Best Answer

Expanding a little on "spaceisdargreen" answer, and to show more details: We are given: $$ M_x(t)=\frac{pe^t}{1-qe^t}$$

Using the moment generating function, the variance is given by: $$ \sigma^2=E[X^2]-(E[X])^2 = \frac{d^2}{dt^2}M_x(t){\Bigr|_{t=0}}-\left(\frac{d}{dt}M_x(t){\Bigr|_{t=0}}\right)^2$$

Notice that if the expected value or mean $E[X]=0$ then $$\sigma^2=E[X^2]=\frac{d^2}{dt^2}M_x(t){\Bigr|_{t=0}}$$ It appears that you assumed the mean was zero, but this is not (presumably) the case.

Now, continuing with the assumption that $p + q = 1$ and $p \ne 0$:

$$ \frac{d}{dt}M_x(t) = \frac{\left(1-qe^t\right)pe^t-pe^t\left(-qe^t\right)}{\left(1-qe^t\right)^2} =\frac{pe^t}{\left(1-qe^t\right)^2}$$

Therefore $$\frac{d}{dt}M_x(t){\Bigr|_{t=0}} = \frac{p}{\left(1-q\right)^2}=\frac{p}{p^2}=\frac{1}{p} $$

Also $$\frac{d^2}{dt^2}M_x(t) = \frac{d}{dt}\left(\frac{pe^t}{\left(1-qe^t\right)^2}\right) = \frac{\left(1-qe^t\right)^2pe^t-pe^t(2)\left(1-qe^t\right)(-qe^t)}{\left(1-qe^t\right)^2}=\frac{pe^t-pq^2e^{3t}}{\left(1-qe^t\right)^4}$$

Therefore $$\frac{d^2}{dt^2}M_x(t){\Bigr|_{t=0}} =\frac{pe^t-pq^2e^{3t}}{\left(1-qe^t\right)^4}{\Bigr|_{t=0}}=\frac{p-pq^2}{\left(1-q\right)^4}=\frac{p(1-q^2)}{\left(1-q\right)^4} = \frac{p(1+q)}{\left(1-q\right)^3}=\frac{1+q}{p^2}$$

Finally, $$ \sigma^2=\frac{d^2}{dt^2}M_x(t){\Bigr|_{t=0}}-\left(\frac{d}{dt}M_x(t){\Bigr|_{t=0}}\right)^2 = \frac{1+q}{p^2} - \left(\frac{1}{p}\right)^2$$ $$=\frac{(1+q)p^2-p^2}{p^4}=\frac{(2-p)p^2-p^2}{p^4}=\frac{(2-p-1)p^2}{p^4}=\frac{(1-p)p^2}{p^4}$$

Hence $$ \sigma^2 = \frac{(1-p)}{p^2}$$