# Question on using the integral of conditional probability to get unconditional probability

I'm trying to solve this problem in my homework assignment and I get different result from the answer. I know the answer is right, but at the same time I also don't see where I did wrong in my solution. So here's the problem:

Let X and Y have a joint uniform distribution on the triangle with vertices (0,0), (3,0), (0,3). Find: (i) E(X|Y) and E(Y|X) (ii) Var(X|Y) and Var(Y|X) (iii) EX and Var(X)

I've correctly completed the first and second sub-problem, but for the third one, I struggle to get it right. I'm trying to use the fact that EX = E(E(X|Y)) to derive EX. And the way I approach it is: EX = $$\int {E(X|Y)*f(Y)} dY$$ where f(Y) is the pdf of Y being a certain value From the sub-problem 1, I have: E(X|Y) = (3-Y)/2 and f(Y) = 3-Y Hence, I tried to solve integration: $$\int{\frac{(3-Y)^2}{2}} dY$$ where 0<=Y<=3 and I get result 4.5 whereas the correct answer is 1.

Can someone please show where I did wrong? I'd much appreciate your help!

The joint density is $\frac{1}{4.5}$ over the triangle. That has not been used in calculating the pdf of $Y$, which is $\frac{3-y}{4.5}$ on $[0,3]$ and $0$ elsewhere.
• The (unconditional) expectation of $X^2$ is indeed $\frac{3}{2}$. Since I am error prone, I checked it two ways. The variance is not $\frac{1}{6}$. – André Nicolas Oct 6 '13 at 17:07