# Finding E((x-a)^2)

#### petvii

##### New Member
Hi all,

Im a fresh statistics student and working on my first course of propability theory. So far everything has been great, but this particular assignment has given me some trouble:

Random variable X's expected value E(X) = 4 and var(X) = 6.

The question is, how do I find E((X-a) ^2)?

I think it has something to do with Y = ag(x) + bh(X) and it's expected value but I don't know how and especially why it is done.

Thank you in advance

#### ondansetron

##### TS Contributor
Is a symbolic of a constant (the same number) subtracted from each X value or is a another RV?

#### petvii

##### New Member
Is a symbolic of a constant (the same number) subtracted from each X value or is a another RV?
I don't know, I guess that is part of the problem.

The assignment is following:
Random variable X's expected value E(X)=4 and Var(X) =6
What is E((X-a)^2) ?

And it contains some hints like:
Random variable X's function Y=ag(X)+bh(X) expected value is E(Y) = E(ag(X) + bh(X))
and Var(X) = E(X^2) - [E(X)]^2

#### Dason

##### Ambassador to the humans
With the information given and according to common convention 'a' would just be an arbitrary constant. So I would just suggest expanding out (X-a)^2 and then using the typical expectation properties.

#### petvii

##### New Member
With the information given and according to common convention 'a' would just be an arbitrary constant. So I would just suggest expanding out (X-a)^2 and then using the typical expectation properties.
Okay I did this and got

Var(X) = E(X^2) - [E(X)]^2
Var(X) = 6 and E(X) = 4
-> E(X^2) = 4^2 + 6 = 22

E((X-a)^2)
= E(X^2-2ax+a^2)
=E(X^2) + E(a^2-2ax)
= 22 + E(a^2-2ax]

But how to solve [E(a^2-2ax)] or did I even get this right so far?

#### Dason

##### Ambassador to the humans
Keep in mind that 'a' is just a number. What can you do in cases where you have something like E(2X)? Is there anything you can do with that? What about something like E(X+5)? Combine those pieces and it might help you out.

#### petvii

##### New Member
Keep in mind that 'a' is just a number. What can you do in cases where you have something like E(2X)? Is there anything you can do with that? What about something like E(X+5)? Combine those pieces and it might help you out.
So do you mean that:
E((X-a)^2) = 22 + E(a^2-2ax) = 22 + E(a^2) + E(-2ax)

EDIT: 22+E(a^2) - 2E(ax)
EDIT2: 22+2a*E(X) + a^2 = a^2 + 8a + 22
EDIT3: a^2 - 8a + 22

and EDIT3 was the right answer. Thank you big time!

Last edited: