Find $E[|X-Y| \mid Y = y ]$ where $X,Y$ are independent $U[0,1]$ variables

101 Views Asked by At

Exercise 12.6 Suppose $X$ and $Y$ are independent $U[0,1]$ variables.

Find the conditional expectation $E(|X-Y| \mid Y=y)$.

Answer is $y^2 - y + \frac12$ but I am not sure why

I calculated 1/3 and have no idea how the y^2 - y + 1/2 is the solution ~ any help would be greatly appreciated. I am not familiar with the script to type in my answer ~ so I attached an image of my hand calculations.

So~ if z =|x-y|

enter image description here

2

There are 2 best solutions below

0
On

$E[(|X-Y|) | Y = y] = P(X < y)\cdot E[Y-X | Y=y$ and $X < y] + P(X > y)\cdot E[X-Y | Y=y$ and $X > y]$

$P(X < Y | Y = y) = y$

$P(X>y|Y=y) = 1-y$

so $E[(|X-Y|) | Y = y] = y\cdot E[y-X |X < y] + (1-y)\cdot E[X-y | X > y]$

$ = y\int_0^y(y-x)\cdot f(x|X<y) dx + (1-y) \int_y^1(x-y)f(x|X>y)dx$

Since $X$ is uniform, so is its conditional.

$f(x|X<y) = 1/y$

$f(x|X>y) = 1/(1-y)$

So we have $E[(|X-Y|) | Y = y] = y\cdot E[y-X |X < y] + (1-y)\cdot E[X-y | X > y] = $

$$y\int_0^y(y-x)\cdot 1/y dx + (1-y) \int_y^1(x-y)]\cdot1/(1-y)dx$$ $$ = \int_0^y(y-x) dx + \int_y^1(x-y)] dx$$ $$ = y^2 - y + 1/2$$

1
On

Your approach should use the relevant conditional probability:

Let $Z=\lvert X-Y\rvert$ then $X\,{\in}\,\{Y+Z,Y-Z\}$

$$\begin{align}f_{\small Z,Y}(z,y) &= f_{\small X,Y}(y-z,y)+f_{\small X,Y}(y+z,y)\\[1ex]&=\mathbf 1_{0<y-z<1,0<y<1}+\mathbf 1_{0<y+z<1,0<y<1}\\[1ex]&=\mathbf 1_{0<z<y<1}+\mathbf 1_{0<y<1-z<1}\\[2ex]f_{\small Z\mid Y}(z\mid y)&=\left(\mathbf 1_{0<z<y}+\mathbf 1_{0<z<1-y}\right)\,\mathbf 1_{0<y<1}\\[2ex]\mathsf E(Z\mid Y\,{=}\,y)&=\left(\int_0^y z\,\mathrm d z+\int_0^{1-y}z\,\mathrm d z\right)\mathbf 1_{0<y<1}\\[1ex]&=\tfrac 12\left(y^2+(1-y)^2\right)\mathbf 1_{0<y<1}\\[1ex]&=\left(y^2-y+\tfrac12\right)\mathbf 1_{0<y<1}\end{align}$$


However, there is no need to mess with conditional probabilities. $X$ and $Y$ are independent, so:-

$$\begin{align}\operatorname{\mathsf E}\left({\raise{2ex}{}}\lvert X-Y\rvert~\middle\vert~ Y=y\right) &= \mathsf E(\lvert X-y\rvert)\\[1ex]&=\mathsf E\big((y-X)\mathbf 1_{\small X\lt y}+(X-y)\mathbf 1_{\small y\leqslant X}\big)\\[1ex]&=\int_{0}^y (y-x)\,\mathrm d x+\int_y^1 (x-y)\,\mathrm d x\\[1ex]&=y^2-\tfrac 12y^2+\tfrac 12(1-y^2)-y(1-y)\\[1ex]&=\tfrac 12-y+y^2\end{align}$$