# Distribution of a binomial variable squared

If I know $X$ is a binomial random variable, how can I find the distribution of $X$ squared (I know that $P(Y=y=x^2) = p(X=x)$ but does this distribution have a standard name)? In particular, how can I find its expected value?

Thanks!

EDIT:

Thank you all! (-:

• You don't have to find the distribution of $X^2$ to find its expected value. You just have to find $\text{E}(X^2)$ using the defintion $\text{E}(X^2) = \sum x^2P[X = x]$. Jun 27, 2014 at 7:41
• (1) yes, but I do want to find (also) its distiribution... (2) in this case where X is binomial variable, how do I find this sum? Jun 27, 2014 at 7:43
• The distribution is just $P(Y = y) = P(X = \sqrt{y})$ if $y$ is a perfect square, and $0$ otherwise. Jun 27, 2014 at 7:47
• $$P[X = k] = ^nC_{\sqrt k} \, p^{\sqrt k} q^{n - \sqrt k}, k = 0, 1, 4, \ldots, n^2$$ Jun 27, 2014 at 7:48

Hint: You can use the fact that $$Var(X)=E(X^{2})-E(X)^{2}$$

to find $$E(X^{2})$$. This is assuming you know both the mean and variance of a binomial random variable

Usually we derive the variance of the binomial distribution from the calculation of its second moment, so to refer to the variance in order to get the second moment would be somewhat circular reasoning.

The direct calculation is as follows. Consider \begin{align*} {\rm E}[X(X-1)] &= \sum_{k=0}^n k(k-1) \binom{n}{k} p^k (1-p)^{n-k} \\ &= \sum_{k=2}^n \frac{n(n-1)(n-2)!}{(k-2)!((n-2)-(k-2))!} p^2 p^{k-2} (1-p)^{(n-2)-(k-2)} \\ &= n(n-1)p^2 \sum_{k'=0}^{n-2} \frac{(n-2)!}{(k')!((n-2)-k')!} p^{k'} (1-p)^{(n-2)-k'} \\ &= n(n-1)p^2 \sum_{k'=0}^{n-2} \binom{n-2}{k'} p^{k'} (1-p)^{(n-2)-k'} \\ &= n(n-1)p^2, \end{align*} because the summand in the penultimate step is simply the probability mass function of a binomial random variable with parameters $$n-2$$ and $$p$$, so it sums to $$1$$ (which is also evident via the binomial theorem). Indeed, this calculation is easily generalized: $${\rm E}[X(X-1)\cdots(X-m)] = \frac{n!}{(n-m-1)!}p^{m+1},$$ for which the above is the special case $$m = 1$$. For $$m = 0$$, we easily get $${\rm E}[X] = np$$. Then combining these results via the linearity of expectation gives $${\rm E}[X^2] = {\rm E}[X(X-1) + X] = {\rm E}[X(X-1)] + {\rm E}[X] = n(n-1)p^2 + np.$$

\begin{align} \text{E}(X^2) & = \sum\limits_{k = 0}^n k^2P[X = k]\\ & = \sum\limits_{k = 0}^n k^2\,^nC_kp^kq^{n - k}\\ & = \sum\limits_{k = 1}^n k^2\, \dfrac{n!}{k! (n - k)!} p^kq^{n - k}\\ & = \sum\limits_{k = 1}^n k \dfrac{n!}{(k - 1)! (n - k)!} p^kq^{n - k}\\ & = \sum\limits_{k = 1}^n (k - 1 + 1) \dfrac{n!}{(k - 1)! (n - k)!} p^kq^{n - k}\\ & = \sum\limits_{k = 1}^n (k - 1) \dfrac{n!}{(k - 1)! (n - k)!} p^kq^{n - k} + \sum\limits_{k = 1}^n \dfrac{n!}{(k - 1)! (n - k)!} p^kq^{n - k}\\ & = \sum\limits_{k = 2}^n \dfrac{n!}{(k - 2)! (n - k)!} p^kq^{n - k} + \sum\limits_{k = 1}^n \dfrac{n!}{(k - 1)! (n - k)!} p^kq^{n - k}\\ & = n(n-1)p^2\sum\limits_{k = 2}^n \dfrac{(n-2)!}{(k - 2)! (n - k)!} p^{k-2}q^{(n-2) - (k-2)} +\\& \qquad np\sum\limits_{k = 1}^n \dfrac{(n-1)!}{(k - 1)! (n - k)!} p^{k-1}q^{(n-1) - (k-1)}\\ & = n(n-1)p^2\sum\limits_{k=2}^n \, ^{n-2}C_{k-2}p^{k-2}q^{(n-2) - (k-2)} + np\sum\limits_{k = 1}^n \, ^{n-1}C_{k-1} p^{k-1}q^{(n-1) - (k-1)}\\ & = n(n - 1)p^2(p + q)^{n - 2} + np(p + q)^{n - 1}\\ & = n^2p^2 - np^2 + np\\ & = \boxed{n^2p^2 + npq} \end{align}

• This is a great explanation, can you explain how $n(n-1)p^2\sum\limits_{k=0}^n \, ^{n-2}C_{k-2}p^{k-2}q^{(n-2) - (k-2)}$ becomes $n(n-1)p^2(p+q)^{n-2}$? Aug 4, 2020 at 5:29
• @JacobB Actually the lower limit of that summation should be $2$. I forgot to write that before, but I've updated the answer now. And changing that limit is alright because in the original summation, the first term (for $k = 1$) is $0$. So in fact, before cancelling the $k - 1$, the first term has to be removed from the summation by updating the limit to $k = 2$. A similar logic applies in the initial steps, where the limit is changed from $k = 0$ to $k = 1$. Aug 5, 2020 at 9:25
• @JacobB Now, as to why $\sum_{k = 2}^n {}^{n-2}C_k p^{k-2}q^{(n-2)-(k-2)}$ is equal to $(p + q)^{n - 2}$… Note that if we expand this summation, it is $$q^{n - 2} + {}^{n-2}C_1 p q^{n-1} + {}^{n-2}C_2 p^2 q^{n - 2} + \cdots + p^{n-2}$$ which is the binomial expansion of $(p + q)^{n - 2}$. In other words, if we let $m = n - 2$ and $r = k - 2$, then $\sum_{k = 2}^n {}^{n-2}C_k p^{k-2}q^{(n-2)-(k-2)}$ becomes $\sum_{r = 0}^m {}^mC_r p^r q^{m - r}$, which is even more clearly the binomial expansion of $(p + q)^m = (p + q)^{n - 2}$. Aug 5, 2020 at 9:29

Consider $f(s) =E s^X$.

$$f(s) = \sum_{k=0}^n \binom nk s^kp^k(1-p)^{n-k} = (1-p+sp)^n \\ EX^2 = \sum_{k=0}^n \binom nk k^2 p^k(1-p)^{n-k} = f'(1) + f''(1) = np + n(n-1)p^2$$

Hint: $E[X^2] = E[X]^2+\text{Var}[X]$. Do you know the mean and variance of $X$?

EDIT: Since a few other answers have shown a derivation of the mean and variance of a binomial random variable, I'll show one as well.

If $X \sim \text{Binomial}(n,p)$, then we can write $X = \displaystyle\sum_{k = 1}^{n}Y_i$ where $Y_i$ are i.i.d. $\text{Bernoulli}(p)$.

Each $Y_i$ takes the value $1$ with probability $p$ and $0$ with probability $1-p$.

Hence, $E[Y_i] = p \cdot 1 + (1-p) \cdot 0 = p$ and $\text{Var}[Y_i] = p \cdot (1-p)^2 + (1-p) \cdot (0-p)^2 = p(1-p)$.

By linearity of expectation, $E[X] = np$. Since the $Y_i$'s are independent, $\text{Var}[X] = np(1-p)$.

Therefore, $E[X^2] = E[X]^2+\text{Var}[X] = (np)^2+np(1-p)$.

In addition to Vinay's comment on finding $\mathbf{E}X^2$, you can easily find the distribution of $X^2$ by squaring the values that $X$ takes (i.e $0,1, 4, 9, \ldots$).