Conditional Expected Value of a Joint Probability Density Function I was wondering if anyone could help me with the following question specifically:
The continuous random variables $X_1$ and $X_2$ have the following joint probability density function: $$f(x_1,x_2)=\frac2{27}$$ over $0< x_1< 3$ and $0< x_2< 9-3x_1.$
Find $$E(X_1\mid X_2=5).$$
I tried to use the method of integrating $xh(x_1\mid x_2)$ but I couldn't get it to work.  Thank you in advance!
 A: Hint:
Note that the PDF is constant on the support.
So $X_1$ has uniform distribution under condition $X_2=5$. 
This with support $[0,\frac43]$.
A: Detailed calculation using no intuition
The conditional expectation of $X_1$ given that $X_2=5$ can be calculated if we know the corresponding conditional density, $f_{X_2\mid X_1=5}(x_2).$ This conditional density can be calculated as follows:
$$f_{X_1\mid X_2=5}(x_1)=\frac{f_{X_1,X_2}(x_1,5)}{f_{X_2}(5)}=\frac{\frac2{27}}{f_{X_2}(5)}$$
where $f_{X_2}(5)$ is the marginal pdf of $X_2$ at $x_2=5$.
Now, the marginal density of $X_2$ is the integral of the common density with respect to $x_1$:
$$f_{X_2}(x_2)=\int_0^{3-\frac13x_2}f(x_1,x_2)\ dx_1=\frac2{27}\left(3-\frac13x_2\right)$$
if $0\leq x_2\leq 9$
So, $$f_{X_2}(5)=\frac8{3^4}.$$
That is $$f_{X_1\mid X_2=5}(x_1)=\frac34$$
if $0\leq x_1\leq \frac43$.
Indeed, this is uniform over $[0,\frac43]$ . The conditional expectation is then $$\frac23$$ (half of $\frac43$) "because"
$$\frac34\int_0^{\frac43}x_1\ dx_1=\frac23.$$
A: From the definition of conditional expectation, 
\begin{equation}
\mathbb{E}(X_{1}|X_{2} = x_{2}) = \int_{-\infty}^{\infty}x_{1}f_{X_{1}|X_{2}}(x_{1}|x_{2})\, dx_{1}.
\end{equation}
Furthermore, 
\begin{equation}
f_{X_{1}|X_{2}}(x_{1}|x_{2}) = \dfrac{f_{X_{1}, X_{2}}(x_{1}, x_{2})}{f_{X_{2}}(x_{2})},
\end{equation}
and
\begin{equation}
f_{X_{2}}(x_{2}) = \int_{x_{1}} f_{X_{1}, X_{2}}(x_{1}, x_{2}) \, dx_{1} = \int_{0}^{\frac{9-x_{2}}{3}} \dfrac{2}{27} dx_{1} = \dfrac{2}{27} \times \dfrac{9-x_{2}}{3}.
\end{equation}
Therefore, 
\begin{align}
\mathbb{E}(X_{1}|X_{2} = 5) & = \int_{-\infty}^{\infty} x_{1}f_{X_{1}|X_{2}}(x_{1}|x_{2} = 5) \, dx_{1} \\
& = \int_{-\infty}^{\infty} x_{1} \dfrac{2/27}{\frac{2}{27} \times \frac{9-5}{3}} \, dx_{1} = \int_{0}^{\frac{9-5}{3}}\dfrac{3x_{1}}{4}\, dx_{1} \\
& = \dfrac{3}{4} \times \left.\dfrac{x_{1}^{2}}{2}\right\vert_{0}^{4/3} = \dfrac{3}{4} \times \dfrac{(4/3)^{2}}{2} = \dfrac{2}{3}
\end{align}
