# Variance of Negative Binomial Distribution/Second Form

## Theorem

Then the variance of $X$ is given by:

$\var X = \dfrac {n q} {p^2}$

where $q = 1 - p$.

## Proof

$\var X = \map {\Pi_X} 1 + \mu - \mu^2$

where $\mu = \expect X$ is the expectation of $X$.

$\map {\Pi_X} s = \dfrac {p s} {1 - q s}$
$\mu = \dfrac n p$
$\dfrac {\d^2} {\d s^2} \map {\Pi_X} s = \paren {\dfrac {p s} {1 - q s} }^{n + 2} \paren {\dfrac {n \paren {n - 1} + 2 n q s} {\paren {p s^2}^2} }$

Putting $s = 1$ and using the formula $\map {\Pi_X} 1 + \mu - \mu^2$:

 $\ds \var X$ $=$ $\ds \paren {\frac p {1 - q} }^{n + 2} \paren {\frac {n \paren {n - 1} + 2 n q} {p^2} } + \frac n p - \frac {n^2} {p^2}$ $\ds$ $=$ $\ds \paren {\frac p p}^{n + 2} \paren {\frac {n \paren {n - 1} + 2 n q} {p^2} } + \frac {n \paren {1 - q} } {p^2} - \frac {n^2} {p^2}$ as $q = 1 - p$ and so $p = 1 - q$ $\ds$ $=$ $\ds \frac {n^2 - n + 2 n q + n - n q - n^2} {p^2}$ gathering terms and multiplying out $\ds$ $=$ $\ds \frac {n q} {p^2}$ simplification

$\blacksquare$