2

Let X be Uniform Random Variable on [0,1]. Y is Uniform Random Variable on [0,2]. Given that X and Y are independent, calculate E[|X-Y|].

I have tried calculating the answer using two different methods - both of which I think are correct approaches - but each produces differing results of 2/3 and 3/4.

Method 1) $$\int_{0}^2\int_{0}^1 (|x-y|/2)dxdy$$ I plug the following into Wolfram Alpha and get 2/3: Wolfram calculation

I'm pretty sure this a correct way of going about getting the expected value, since in general for independent x and y, E[g(x,y)] = $$\int_{a}^b\int_{c}^d g(x,y)f(x)f(y)dxdy$$ where of course f(x) and f(y) are the respective distributions of random variables X and Y, and in this particular instance is (1/2)*(1) = (1/2).

Method 2) E[X-Y|X>Y] + E[Y-X|Y>X]. This method yields me 3/4 when I calculate it. The first integral is $$\int_{0}^1\int_{0}^x (.5(x-y))dydx$$ This equals 1/12. The second integral is $$\int_{0}^2\int_{0}^y (.5(y-x))dxdy$$ This equals 2/3. (2/3) + (1/12) = (3/4).

I'm also fairly certain this is a correct procedure, since there are 3 cases: X>Y, X=Y, and X<Y. X=Y will always produce |X-Y|=0. If X>Y, then |X-Y| = X-Y. If X<Y, then |X-Y| = Y-X. Summing the expectations should yield me a correct result.

Which answer is correct (or neither)? Have I made a careless computational blunder in one of the methods? Or is one of the methods I used a fundamentally incorrect approach to solving the given problem?

EDIT: So, Method 2 is full of errors on my part, which can be noted in the comment section. While I'm certain the correct answer is 2/3, I have found a line of reasoning that yields 3/4 using conditional expectation that I am not able to disprove.

E[|X-Y|] = Pr(Y>1)(E[Y-X|Y>1]) + Pr(X>Y)(E[X-Y|X>Y]) + Pr(Y>X And 0<Y<1)*(E[Y-X|Y>X And 0<Y<1])

Pr(Y>1) = 1/2

Pr(X>Y) = 1/4

Pr(Y>X and 0<Y<1) = 1/4

E[Y-X|Y>1] = 1 (this is intuitive if you think about the symmetry)

E[Y-X|Y>X And 0<Y<1] = E[X-Y|X>Y] (once again intuitive by symmetry)

Now, by linearity of expectation, E[X|X>Y] - E[Y|X>Y] = E[X-Y|X>Y] = 0.5. Given what we know about Y, it is fair to treat Y as uniform on [0,1] in this instance. Therefore, if we expect X to be 0.5, then Y is uniform on [0,0.5], giving expectation of 0.25. The same logic applies in reverse to give us E[X|X>Y] = 0.75. You can see integral proof here: OSU Conditional Expectation Slides.

Finally, summing it all up, (1/2)(1) + (1/4)(1/2) + (1/4)*(1/2) = 3/4.

Can anyone see where I went wrong with my logic on the conditional expectation? In general, when you apply the above procedure, I think what is being spit back is actually the average of the means of X and Y. However, I'm unsure where the logic is breaking down.

StubbornAtom
  • 18,135
  • In your second approach, aren't you supposed to weight the sum with the probabilities of the events $X>Y$ and $X<Y$? – dfnu Sep 15 '20 at 20:08
  • @dfnu Yes thanks for pointing that out! I forgot you'd want to multiply by 1/(Pr[X>Y]) and 1/(Pr[X<Y]) in each case, respectively. However, that still leaves us at odds with the Wolfram calculation, I think. Pr(Y>X) = 3/4, therefore Pr(Y<X) = 1/4. (1/(1/4))(1/12) + (1/(3/4))(2/3) = (1/3) + (8/9) = 11/9. So, again, at conflict with the 2/3 that Wolfram is producing – math_guy_1616 Sep 15 '20 at 21:22
  • Your first result, that is $\frac23$, is definitely correct. I think you should consider more carefully the way you compute conditional expectations. For example, what is the density of $(X,Y)$, conditioned on $X>Y$? Is it still equal to $\frac12$ over the range $0<y<x<1$? Also, referring to your comment, you should multiply and not divide, I guess, by the probabilities of $X>Y$ and $X<Y$. – dfnu Sep 15 '20 at 22:36
  • It seems to me the density would be (1/x), since X is uniformly distributed between 0 and 1 and Y is distributed uniformly between 0 and X. I can also see that my second integral is incorrect in that we cannot bound X from 0 to Y. We must separate into the cases where Y is between 0 and 1 and Y is between 1 and 2. For the first case, X is uniformly distributed between 0 and Y, and for the second X is uniformly distributed between 0 and 1. However, even with these densities I am failing to reproduce 2/3. Is there an integral equation you have come up with that produces 2/3? – math_guy_1616 Sep 16 '20 at 00:08
  • @dfnu With probability 1/2, Y > 1. In that case, E[|X-Y|] = 1. For the remaining 1/2 of outcomes, we can treat Y as uniform on [0,1]. X will be greater than Y half the time, and Y will be greater than X half the time. By linearity of expectation, E[X|X>Y] - E[Y|X>Y] = E[X-Y|X>Y]. Given that in these cases we treat Y as uniform on [0,1], E[X|X>Y] = 0.75 and E[Y|X>Y] = 0.25. The difference is 0.5. We end up with (1/2)(1) + (1/4)(1/2) + (1/4)*(1/2) = 3/4. Once again I am confused in the discrepancies. – math_guy_1616 Sep 16 '20 at 03:04
  • I think your intuition fails somewhere when determining the values of conditional expectations. Consider for instance $E[X|X>Y]$. We need the conditional density of $X$ given the event $X>Y$. So compute first $$P(X<x|X>Y) = \frac{P(X<x \land X > Y)}{P(X>Y)}=x^2, \ \ \ 0<x<1.$$ To see this, note the the numerator of the above expression is equal to $\frac14$, and the numerator is $$\frac12 \int_0^x\int_0^x dy dx=\frac{x^2}4.$$ Thus, differentiating, $$f_X(x|X>Y) = 2x, \ \ 0 < x <1,$$and $$E[X|X>Y]=\int_0^1 xf_X(x|X>Y) dx = \int_0^1 2x^2dx = \frac23.$$ – dfnu Sep 16 '20 at 07:39

1 Answers1

2

Can anyone see where I went wrong with my logic on the conditional expectation?

Here it is!

$$\mathbb{E}|X-Y|=\mathbb{P}[X>Y]\mathbb{E}[X|X>Y]-\mathbb{P}[X>Y]\mathbb{E}[Y|X>Y]+\mathbb{P}[X<Y]\mathbb{E}[Y|X>Y]-\mathbb{P}[X<Y]\mathbb{E}[X|X>Y]$$

$$\frac{1}{4}\times \frac{2}{3}-\frac{1}{4}\times \frac{1}{3}+\frac{3}{4}\times \frac{11}{9}-\frac{3}{4}\times \frac{4}{9}=\frac{2}{3}$$

Sketch of calculations:

$$\mathbb{E}[X|X>Y]=2\int_{0}^{1}x\Bigg[\int_{0}^{ x} dy\Bigg]dx=\frac{2}{3}$$

$$\mathbb{E}[Y|X>Y]=2\int_{0}^{1}\Bigg[\int_{0}^{ x} ydy\Bigg]dx=\frac{1}{3}$$

This because looking at a drawing you see that the distribution is uniform over a triangle with area $0.5$

Similar brainstorming for the other probabilities

$$\mathbb{E}[Y|X<Y]=\frac{2}{3}\int_{0}^{1}\Bigg[\int_{x}^{ 2}y dy\Bigg]dx=\frac{11}{9}$$

$$\mathbb{E}[X|X<Y]=\frac{2}{3}\int_{0}^{1}x\Bigg[\int_{x}^{ 2} dy\Bigg]dx=\frac{4}{9}$$


A third way to solve the problem is the following:

$$\mathbb{E}|X-Y|=\mathbb{E}[Max(X,Y)]-\mathbb{E}[min(X,Y)]$$

Let's set $U=Max(X,Y)$ and $V=min(X,Y)$.

It is very easy to calculate the two CDF's

$$F_U(u) = \begin{cases} 0, & \text{if $u<0$ } \\ \frac{u^2}{2}, & \text{if $0\leq u<1$ } \\ \frac{u}{2}, & \text{if $1\leq u<2$ } \\ 1, & \text{if $u \geq2$} \end{cases}$$

$$F_V(v) = \begin{cases} 0, & \text{if $v<0$ } \\ 1-(1-v)(1-\frac{v}{2}), & \text{if $0\leq v<1$ } \\ 1, & \text{if $v \geq1$} \end{cases}$$

now remembering that with non-negative rv we have

$$\mathbb{E}[X]=\int_{0}^{\infty}\bigg[1-F_X\Bigg]dx$$

immediately we get also

$$\mathbb{E}|X-Y|=\mathbb{E}[U]-\mathbb{E}[V]=\frac{13}{12}-\frac{5}{12}=\frac{2}{3}$$

tommik
  • 33,251