# How to compute $E(X(X-1))$ ($X$ has a Binomial distribution)

I'm a newbie in Probability. The book "Introduction to Probability" by Joseph K. Blitzstein and Jessica Hwang page 161 in the Expectation chapter in section Variance talks about Binomial Variance but also involve deriving the variance from using indicator random variables (I know there is other way of doing it but my question is about this specific method).

The book says: Alternatively, we can find $E(X^2)$ by first finding $E{X \choose 2}$. Since ${X \choose 2}$ is the number of pairs of successful trials. Creating an indicator r.v. for each pair of trials, we have: $$E{X \choose 2} = {n \choose 2}p^2$$

I understand this part that there is pairs of successful trial from all n trials so there are ${n \choose 2}$ of it and each with probability $p * p = p^2$

then it says:

Thus,

$$n(n-1)p^2 = E(X(X-1)) = E(X^2) - E(X) = E(X^2) - np$$ I do not understand why: $n(n-1)p^2 = E(X(X-1))$ ???

I need not only word explanation but I also would like to know the mathematical step by step computation. please show it. It seems like it relates to Law of the unconscious statistician (LOTUS) but LOTUS talks about $E(g(X))$ but this problem is like E(g(X(something...))). please give word explanation and step by step mathematical computation. Does Linearity of Expectation also involve? but it only talks about E(cX) and E(X+Y) isn't it? in this case it is E(random variable(random variable)) ???

in your case $g(x)=x\cdot(x-1)$ and you can use LOTUS.
But I think what the author had in mind is the following: $${X\choose{2}}= \frac{X\cdot (X-1)}{2}, \quad \text{and} \quad \Bbb E{X\choose{2}}= \Bbb E \biggl( \frac{X\cdot (X-1)}{2}\biggr) = \frac 12 \Bbb E \bigl({X\cdot (X-1)}\bigr).$$ Note that I pulled out the factor $\frac 12$ using the linearity of expectation.
Since you understand that $$\Bbb E {X\choose{2}} = {n\choose{2}}p^2 = \frac {n\cdot(n-1)}{2}p^2$$ it now follows that $$\frac {n\cdot(n-1)}{2}p^2 = \Bbb E {X\choose{2}} = \frac 12 \Bbb E \bigl({X\cdot (X-1)}\bigr).$$ Cancelling $\frac 12$ on both sides gives you your desired result.
• Wow. Thank you very much for great answer. Can you also please Add answer in the LOTUS form. It would be so so great ^^. can we use $x*(x-1)$ or we need $x^2-x$ for the LOTUS form? or we can do both? Commented Jan 5, 2017 at 8:16
• you can do both. Here is the beginning of Lotus: $$\Bbb E (X (X-1)) = \sum_{k=1}^n k\cdot (k-1) {n \choose k} p^k (1-p)^{n-k}.$$ From here you can split up the sum and compute each component separately. Commented Jan 5, 2017 at 8:20