# Is this method of finding the expected value of the square a random variable correct?

Suppose x is a discrete random variable with values 2,3,1 and probabilities 0.2,0.3, and 0.4 respectively. NOw say we have the function y=x2+3 and we want to find the expected value of this equation. So, in my opinion, we first have to square all the values of x so they become 4,9 and 1 and then multiply them with their respective probabilities and then add them all up and in the end, just add 3 to the answer.

This works out to give the answer 6.9, but my teacher at the university solvedthis question another way. He said that since x2 is just x times x, the expected value of x squared should be the E(x) times E(x) so we can just multiply the value of x with its probability and then add em all up and then square the answer. This gives the answer 5.89. So which way is correct?

I'm pretty sure that the way I think it should be done is correct so if it is, then I'm gonna have to confront my teacher about this matter. And I just know that he'll state the rule that the expected value of the product of two or more random variables is equal to the product of their individual expected values. How do I explain to him why this rule doesn't apply here?

I think it is because of the rule applies to two different random variables, but here x is the same random variable.

• Just to clarify, you're calculating $\bar{y}$ rather than $\langle y \rangle$. You're calculating the average value of y over a sample, rather than the expected value of y – gazza89 Oct 16 '18 at 12:27
• en.wikipedia.org/wiki/Law_of_the_unconscious_statistician – Kodiologist Oct 16 '18 at 12:58
• @Ferdi hmm.. can you elucidate? – NoLifeKing Oct 16 '18 at 16:09

$$E[X]=\sum_i x_i f(x_i)$$
$$E[X^2]=Var[X]+E[X]^2$$
We can see that in general $$E[X^2] \neq E[X]^2$$, unless $$Var[X]=0$$