# Thread: Finding the expected value of x^2 in binomial distribution

1. ## Finding the expected value of x^2 in binomial distribution

Here is the summation (from i=0 to n) of i^2 * (n!/(n-i)!(i!)) * p^i * q^(n-i)

I know that the answer is equal to np[(n-1)p+1].

I am not really sure how to get what is in the bracket of the answer.

Thanks.

2. There are easier ways to do this than evaluating that sum

You know that
$E(X^2) = Var(X) + E^2(X)$

You also know that by definition the binomial variable X is the sum of n independant bernoulli trials. Its not difficult to compute the mean and variance of the sum of n independant bernoulli trials, then you can use the result above.

3. THank you for your quick reply.

However, I would actually like to know how to get that answer, which is np[(n-1)p+1] using the summation and binomial distribution properties.

Could you please show me the steps?

4. Instead of recognising the left hand sum as an expectation, you can use the algebra in the following link to show explicitly that it is (n-1)p.
Mean or Expectation Value

Spoiler:

latex in case i need it later
\begin{eqnarray*}
E(X^2) &=& \sum_{i=0}^n \left( i^2 \frac{n!}{i!(n-i)!} p^{i} (1-p)^{n-i}\right)\\
&& \text{note first term in sum is 0 and rewrite limit}\\
&=& \sum_{i=1}^n \left( i^2 \frac{n!}{i!(n-i)!} p^{i} (1-p)^{n-i}\right)\\
&=& np\sum_{i=1}^n \left( i \frac{(n-1)!}{(i-1)!(n-i)!} p^{i-1} (1-p)^{n-i}\right)\\
&& \text{let } j=i-1 \text{ , so }i=j+1\\
&=& np\sum_{j=0}^{n-1} \left( i \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)\\
&=& np\sum_{j=0}^{n-1} \left( (j+1) \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)\\
&=& np\sum_{j=0}^{n-1} \left( (j) \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)+ np\sum_{j=0}^{n-1} \left( \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)\\
&& \text{recognise right hand sum as PDF of Bi(n-1,p)}\\
&=& np\sum_{j=0}^{n-1} \left( (j) \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)+ np \times 1\\
&& \text{recognise left hand sum as Expectation of Bi(n-1,p)}\\
&=& np\left((n-1)p \right)+ np \times 1\\
&=& np\left((n-1)p + 1 \right)

\end{eqnarray*}

5. It's easier to find E(X(X-1)) first and then use $E(X(X-1))= E(X^2)-np$