# Expectations as integrals with respect to a joint distribution

As part of self-study, I'm trying to learn about conditional expectation. Example 5 here presents the problem:

"Let $$X_1, X_2$$ be independent with $$U(0, \theta)$$ distribution for some known $$\theta$$. Let $$Y = \max\{X_1, X_2\}$$ and $$X = X_1$$. We want to find the conditional mean of $$X$$ given $$Y$$."

It presents an equation based on "rewrit[ing]...expectations as integrals with respect to the joint distribution of $$(X_1, X_2)$$:" $$\int_0^d\int_0^d\frac{x_1}{\theta^2}\mathrm{d}x_1\mathrm{d}x_2 = \int_0^d\frac{3y}{4}\frac{2y}{\theta^2}\mathrm{d}y$$, but I don't really get this. I think the $$\frac{1}{\theta^2}$$ comes from the joint density of $$(X_1, X_2)$$ but I don't understand why there is a double integral for calculating expectation on one side and how there is a $$2$$ on the other side.

Can I have some guidance on how this rewriting was done?

• John, I have added the self-study. Please see its scope and relevance. Commented Feb 8, 2023 at 13:03
• Those are strange notes: the first paragraph of Example 5 is what I would have said; the second paragraph is a check that it works when calculating $\mathbb E[X \, I_{[Y<d]} ]$ two different ways; while the final throwaway point on $h^\prime$, while true, is so brief that it seems designed to confuse somebody learning about conditional expectation. Commented Feb 8, 2023 at 14:50
• @Henry agreed, the point about $h'$ does not sit at all well with the rest of the example. Commented Feb 8, 2023 at 17:03

Given the intuitive answer is $$E[X|Y] = \frac{3}{4}Y$$, the ultimate goal is to show for $$0 < d < \theta$$, \begin{align} \int_{[Y \leq d]} XdP = \int_{[Y \leq d]} \frac{3}{4}YdP. \tag{1} \end{align} The linked note evaluates the left hand side of $$(1)$$ using the joint distribution of $$(X_1, X_2)$$ while evaluates the right hand side of $$(1)$$ using the law of the unconscious statistician (i.e., deriving the marginal distribution of $$Y$$ first, but this step is omitted in the note -- and it is recovered in S. Catterall's answer). In fact, you don't have to follow this procedure to verify $$(1)$$, it is still perfectly fine to evaluate the right hand side of $$(1)$$ using the joint density of $$(X_1, X_2)$$, and this is equally clear: \begin{align} & \int_{[Y \leq d]} \frac{3}{4}Y dP \\ =& \int_{[\max(X_1, X_2) \leq d]} \frac{3}{4}\max(X_1, X_2)dP \\ =& \int_{[X_1 \leq d] \cap [X_2 \leq d]}\frac{3}{4}\max(X_1, X_2)dP \\ =& \frac{3}{4}\int_0^d\int_0^d\max(x_1, x_2)\frac{1}{\theta^2}dx_1dx_2 \\ =& \frac{3}{4\theta^2}\int_0^d\left[\int_0^{x_2}x_2dx_1 + \int_{x_2}^dx_1dx_1\right]dx_2 \\ =& \frac{3}{4\theta^2}\int_0^d\left[x_2^2 + \frac{1}{2}d^2 - \frac{1}{2}x_2^2\right]dx_2 \\ =& \frac{3}{4\theta^2}\left(\frac{1}{6}d^3 + \frac{1}{2}d^3\right) \\ =& \frac{d^3}{2\theta^2}, \end{align} which is equal to \begin{align} \int_{[Y \leq d]} X dP = \int_0^d\int_0^dx_1\frac{1}{\theta^2}dx_1dx_2 = \frac{d^3}{2\theta^2}. \end{align}
This completes the verification of $$(1)$$ hence $$E[X|Y] = \frac{3}{4}Y$$.
You're right, $$f(x_1,x_2)=\frac{1}{\theta^2}I(0 is the joint density of $$(X_1, X_2)$$. The left hand side $$E(X_1 I(Y is computed using $$E(g(X_1,X_2))=\int g(x_1,x_2)f(x_1,x_2) dx_1 dx_2$$ where in this particular case $$g(x_1,x_2)=x_1 I(\max(x_1, x_2). The right hand side $$E([3Y/4]I(Y only involves $$Y$$, so it's easier to handle if we can obtain the density of $$Y$$. This density can be obtained by differentiating the cdf of $$Y$$, and you should obtain $$f(y)=\frac{2y}{\theta^2}$$.
Note: you could also calculate the right hand side as a double integral, explicitly rewriting $$Y$$ as $$\max(X_1,X_2)$$. This is perfectly possible, but the stated approach is easier if you are familiar with the density of $$Y$$.
• Because often questions like this originate in less-than-explicit handling of the support of the distribution, it would help to modify your assertion that $1/\theta^2$ is the joint density. The correct statement -- one that begins to reveal where the limits of the integrals come from -- is that $1/\theta^2 \mathcal{I}_{[0,1]\times[0,1]}$ is the density.